Skip to content
This repository has been archived by the owner on Oct 23, 2020. It is now read-only.

Commit

Permalink
fix vpn connection creation
Browse files Browse the repository at this point in the history
  • Loading branch information
remijouannet committed Oct 24, 2017
1 parent ced6b6f commit 257f4a4
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 18 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ RUN apk update
RUN apk add bash make git zip
RUN go get -u github.com/kardianos/govendor
RUN go get -u github.com/mitchellh/gox
RUN go get -u github.com/mitchellh/gox
RUN go get -u github.com/aktau/github-release

WORKDIR /go/src/github.com/remijouannet/terraform-provider-osc
Expand Down
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ XC_EXCLUDE_OSARCH="!darwin/arm !darwin/386"
VERSION=$$(git describe --abbrev=0 --tags)
PWD=$$(pwd)

COMMIT=$$(git rev-parse HEAD)
GOOS=$$(go env GOOS)
GOARCH=$$(go env GOARCH)

default: build

build: fmt
Expand All @@ -25,7 +29,12 @@ pkg: fmt
echo "==> Building..."
CGO_ENABLED=0 gox -os=$(XC_OS) -arch=$(XC_ARCH) \
-osarch=$(XC_EXCLUDE_OSARCH) \
-output ./pkg/terraform-provider-osc_{{.OS}}_{{.Arch}}_$(VERSION)/terraform-provider-osc-$(VERSION) .
-output ./pkg/terraform-provider-osc_{{.OS}}_{{.Arch}}_$(VERSION)/terraform-provider-osc_$(VERSION) .

bin: fmt
mkdir -p ./bin
echo "==> Building..."
CGO_ENABLED=0 gox -os=$(GOOS) -arch=$(GOARCH) -output ./bin/terraform-provider-osc_$(VERSION) .

vet:
@echo "go vet ."
Expand Down Expand Up @@ -53,6 +62,11 @@ test-compile:
release:
bash scripts/github-releases.sh

docker-bin: docker-image
docker run \
-v $(PWD)/bin:/go/src/github.com/remijouannet/terraform-provider-osc/bin \
terraform-provider-osc:$(VERSION) bin

docker-image:
docker build -t terraform-provider-osc:$(VERSION) .

Expand Down
13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,10 @@ Download the binary and put it in the same folder than terraform binary
```
$ wget https://github.com/remijouannet/terraform-provider-osc/releases/download/v0.1/terraform-provider-osc_darwin_amd64_v0.1.zip
$ unzip terraform-provider-osc_darwin_amd64_v0.1.zip
$ mv terraform-provider-osc_darwin_amd64_v0.1/terraform-provider-osc-v0.1 ~/bin/
$ chmod +x ~/bin/terraform-provider-osc-v0.1
$ mkdir ~/.terraform.d/plugins/ && mv terraform-provider-osc_darwin_amd64_v0.1/terraform-provider-osc_v0.1 ~/.terraform.d/plugins/
$ chmod +x ~/.terraform.d/plugins/terraform-provider-osc_v0.1
```

add the following to ~/.terraformrc

```
providers {
osc = "/home/remi/bin/terraform-provider-osc-v0.1"
}
```


Build without docker
---------------------

Expand Down
3 changes: 3 additions & 0 deletions examples/vpn/.terraform/plugins/linux_amd64/lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"osc": "312290aaabe88edbde7cac80712a7d66a966120b5e537bdd5adc973efc68ccb0"
}
11 changes: 11 additions & 0 deletions examples/vpn/cgw.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
resource "osc_customer_gateway" "customer_gw" {
bgp_asn = 65000
ip_address = "149.6.164.226"
type = "ipsec.1"

tags {
project = "${var.project}"
Name = "${var.project}_customergw"
}
}

11 changes: 11 additions & 0 deletions examples/vpn/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
provider "osc" {
profile = "${var.profile}"
region = "${var.region}"
skip_credentials_validation = true
skip_region_validation = true

endpoints {
ec2 = "${var.url_ec2}"
iam = "${var.url_iam}"
}
}
5 changes: 5 additions & 0 deletions examples/vpn/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
profile = "default"
region = "eu-west-2"
url_ec2 = "fcu.eu-west-2.outscale.com"
url_iam = "eim.eu-west-2.outscale.com"
project = "vpn"
5 changes: 5 additions & 0 deletions examples/vpn/vars.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable profile {}
variable region {}
variable url_ec2 {}
variable url_iam {}
variable project {}
7 changes: 7 additions & 0 deletions examples/vpn/vgw.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "osc_vpn_gateway" "vpn_gw" {
vpc_id = "${osc_vpc.vpc.id}"
tags {
project = "${var.project}"
Name = "${var.project}_vpngw"
}
}
8 changes: 8 additions & 0 deletions examples/vpn/vpc.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "osc_vpc" "vpc" {
cidr_block = "192.168.140.0/22"

tags {
project = "${var.project}"
Name = "${var.project}_vpc"
}
}
6 changes: 6 additions & 0 deletions examples/vpn/vpn.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "osc_vpn_connection" "vpnconnection" {
vpn_gateway_id = "${osc_vpn_gateway.vpn_gw.id}"
customer_gateway_id = "${osc_customer_gateway.customer_gw.id}"
type = "ipsec.1"
static_routes_only = false
}
13 changes: 8 additions & 5 deletions osc/resource_osc_vpn_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,13 @@ func xmlConfigToTunnelInfo(xmlConfig string) (*TunnelInfo, error) {
tunnelInfo := TunnelInfo{
Tunnel1Address: vpnConfig.Tunnels[0].OutsideAddress,
Tunnel1PreSharedKey: vpnConfig.Tunnels[0].PreSharedKey,

Tunnel2Address: vpnConfig.Tunnels[1].OutsideAddress,
Tunnel2PreSharedKey: vpnConfig.Tunnels[1].PreSharedKey,
}

}
if len(vpnConfig.Tunnels)== 2 {
tunnelInfo.Tunnel2Address = vpnConfig.Tunnels[1].OutsideAddress
tunnelInfo.Tunnel2PreSharedKey = vpnConfig.Tunnels[1].PreSharedKey
} else {
tunnelInfo.Tunnel2Address = ""
tunnelInfo.Tunnel2PreSharedKey = ""
}
return &tunnelInfo, nil
}

0 comments on commit 257f4a4

Please sign in to comment.