From 0abfda4d8bf23c86eed7d70652fba154e29f92e0 Mon Sep 17 00:00:00 2001 From: Jake Champlin Date: Fri, 19 May 2017 16:44:07 -0400 Subject: [PATCH] provider/aws: Allow lightsail resources to work in other regions Previously lightsail was limited to `us-east-1` only. This restriction has now been lifted to new regions. ``` $ make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSLightsailInstance_euRegion' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/05/19 16:40:48 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSLightsailInstance_euRegion -timeout 120m === RUN TestAccAWSLightsailInstance_euRegion --- PASS: TestAccAWSLightsailInstance_euRegion (45.31s) PASS ok github.com/hashicorp/terraform/builtin/providers/aws 45.319s ``` Fixes: #14668 --- builtin/providers/aws/config.go | 2 +- .../resource_aws_lightsail_instance_test.go | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/config.go b/builtin/providers/aws/config.go index e060dbda9..f736b0b5b 100644 --- a/builtin/providers/aws/config.go +++ b/builtin/providers/aws/config.go @@ -368,7 +368,7 @@ func (c *Config) Client() (interface{}, error) { client.kinesisconn = kinesis.New(awsKinesisSess) client.kmsconn = kms.New(awsKmsSess) client.lambdaconn = lambda.New(sess) - client.lightsailconn = lightsail.New(usEast1Sess) + client.lightsailconn = lightsail.New(sess) client.opsworksconn = opsworks.New(sess) client.r53conn = route53.New(usEast1Sess) client.rdsconn = rds.New(awsRdsSess) diff --git a/builtin/providers/aws/resource_aws_lightsail_instance_test.go b/builtin/providers/aws/resource_aws_lightsail_instance_test.go index 978aed68f..da7bc3b2e 100644 --- a/builtin/providers/aws/resource_aws_lightsail_instance_test.go +++ b/builtin/providers/aws/resource_aws_lightsail_instance_test.go @@ -38,6 +38,30 @@ func TestAccAWSLightsailInstance_basic(t *testing.T) { }) } +func TestAccAWSLightsailInstance_euRegion(t *testing.T) { + var conf lightsail.Instance + lightsailName := fmt.Sprintf("tf-test-lightsail-%d", acctest.RandInt()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "aws_lightsail_instance.lightsail_instance_test", + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSLightsailInstanceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSLightsailInstanceConfig_euRegion(lightsailName), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckAWSLightsailInstanceExists("aws_lightsail_instance.lightsail_instance_test", &conf), + resource.TestCheckResourceAttrSet("aws_lightsail_instance.lightsail_instance_test", "availability_zone"), + resource.TestCheckResourceAttrSet("aws_lightsail_instance.lightsail_instance_test", "blueprint_id"), + resource.TestCheckResourceAttrSet("aws_lightsail_instance.lightsail_instance_test", "bundle_id"), + resource.TestCheckResourceAttrSet("aws_lightsail_instance.lightsail_instance_test", "key_pair_name"), + ), + }, + }, + }) +} + func TestAccAWSLightsailInstance_disapear(t *testing.T) { var conf lightsail.Instance lightsailName := fmt.Sprintf("tf-test-lightsail-%d", acctest.RandInt()) @@ -149,3 +173,17 @@ resource "aws_lightsail_instance" "lightsail_instance_test" { } `, lightsailName) } + +func testAccAWSLightsailInstanceConfig_euRegion(lightsailName string) string { + return fmt.Sprintf(` +provider "aws" { + region = "eu-west-1" +} +resource "aws_lightsail_instance" "lightsail_instance_test" { + name = "%s" + availability_zone = "eu-west-1a" + blueprint_id = "joomla_3_6_5" + bundle_id = "nano_1_0" +} +`, lightsailName) +}