Skip to content

Commit

Permalink
provider/aws: Remove restriction on running aws_opsworks_* on us-east…
Browse files Browse the repository at this point in the history
…-1 (#12688)

Fixes: #11824

A full set of acceptance tests for *all* OpsWorks tests are below. There is a single issue, opsworks_instance isn't ordering the layer_ids so it's non-deterministic which can come back. This introduces a false positive.

The opsworks tests are running both against us-east-1 for some and us-west-2 for others. This must be marked as a backwards incompatibility in 0.9 just incase people are using the opsworks region parameter to try and override the provider region

```
% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSOpsworksApplication'                                                              2 ↵ ✹
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/03/14 17:11:36 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSOpsworksApplication -timeout 120m
=== RUN   TestAccAWSOpsworksApplication
--- PASS: TestAccAWSOpsworksApplication (164.29s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	164.319s
```

```
% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSOpsworksCustomLayer'                                                                  ✹
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/03/14 17:16:18 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSOpsworksCustomLayer -timeout 120m
=== RUN   TestAccAWSOpsworksCustomLayerImportBasic
--- PASS: TestAccAWSOpsworksCustomLayerImportBasic (105.98s)
=== RUN   TestAccAWSOpsworksCustomLayer
--- PASS: TestAccAWSOpsworksCustomLayer (92.68s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	198.684s
```

```
% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSOpsworksPermission'                                                                   ✹
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/03/14 17:23:28 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSOpsworksPermission -timeout 120m
=== RUN   TestAccAWSOpsworksPermission
--- PASS: TestAccAWSOpsworksPermission (226.36s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	226.386s
```

```
% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSOpsworksRailsAppLayer'                          ✹
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/03/14 17:28:01 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSOpsworksRailsAppLayer -timeout 120m
=== RUN   TestAccAWSOpsworksRailsAppLayer
--- PASS: TestAccAWSOpsworksRailsAppLayer (129.39s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	129.426s
```

```
% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSOpsworksUserProfile'                            ✹
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/03/14 17:37:46 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSOpsworksUserProfile -timeout 120m
=== RUN   TestAccAWSOpsworksUserProfile
--- PASS: TestAccAWSOpsworksUserProfile (42.60s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	42.624s
```

```
% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSOpsworksStack'                                                                     2 ↵ ✹
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/03/14 18:00:50 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSOpsworksStack -timeout 120m
=== RUN   TestAccAWSOpsworksStackImportBasic
--- PASS: TestAccAWSOpsworksStackImportBasic (50.28s)
=== RUN   TestAccAWSOpsworksStackNoVpc
--- PASS: TestAccAWSOpsworksStackNoVpc (25.92s)
=== RUN   TestAccAWSOpsworksStackVpc
--- PASS: TestAccAWSOpsworksStackVpc (76.80s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	153.025s
```

```
% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSOpsworksRdsDbInstance'                                                                                                               ✹
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/03/14 17:38:36 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSOpsworksRdsDbInstance -timeout 120m
=== RUN   TestAccAWSOpsworksRdsDbInstance
--- PASS: TestAccAWSOpsworksRdsDbInstance (916.15s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	916.177s
```

```
% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSOpsworksInstance'           2 ↵
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/03/14 17:26:45 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSOpsworksInstance -timeout 120m
=== RUN   TestAccAWSOpsworksInstance_importBasic
--- PASS: TestAccAWSOpsworksInstance_importBasic (85.52s)
=== RUN   TestAccAWSOpsworksInstance
--- FAIL: TestAccAWSOpsworksInstance (114.09s)
	testing.go:268: Step 1 error: After applying this step, the plan was not empty:

		DIFF:

		UPDATE: aws_opsworks_instance.tf-acc
		  layer_ids.0: "4c29b76f-df72-409e-a5c4-9459b7d9b4a4" => "a4a859cf-2a07-447e-a151-a97a6d827db7"
		  layer_ids.1: "a4a859cf-2a07-447e-a151-a97a6d827db7" => "4c29b76f-df72-409e-a5c4-9459b7d9b4a4"

      FAIL
      exit status 1
      FAIL	github.com/hashicorp/terraform/builtin/providers/aws	199.643s
      make: *** [testacc] Error 1
```
  • Loading branch information
stack72 authored Mar 15, 2017
1 parent 9b1ae50 commit 4f58099
Show file tree
Hide file tree
Showing 21 changed files with 133 additions and 223 deletions.
2 changes: 1 addition & 1 deletion builtin/providers/aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func (c *Config) Client() (interface{}, error) {
client.kmsconn = kms.New(sess)
client.lambdaconn = lambda.New(sess)
client.lightsailconn = lightsail.New(usEast1Sess)
client.opsworksconn = opsworks.New(usEast1Sess)
client.opsworksconn = opsworks.New(sess)
client.r53conn = route53.New(usEast1Sess)
client.rdsconn = rds.New(sess)
client.redshiftconn = redshift.New(sess)
Expand Down
60 changes: 30 additions & 30 deletions builtin/providers/aws/resource_aws_opsworks_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ func resourceAwsOpsworksApplication() *schema.Resource {
Update: resourceAwsOpsworksApplicationUpdate,
Delete: resourceAwsOpsworksApplicationDelete,
Schema: map[string]*schema.Schema{
"id": &schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
},
"name": &schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
},
"short_name": &schema.Schema{
"short_name": {
Type: schema.TypeString,
Computed: true,
Optional: true,
},
// aws-flow-ruby | java | rails | php | nodejs | static | other
"type": &schema.Schema{
"type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
Expand All @@ -56,62 +56,62 @@ func resourceAwsOpsworksApplication() *schema.Resource {
return
},
},
"stack_id": &schema.Schema{
"stack_id": {
Type: schema.TypeString,
Required: true,
},
// TODO: the following 4 vals are really part of the Attributes array. We should validate that only ones relevant to the chosen type are set, perhaps. (what is the default type? how do they map?)
"document_root": &schema.Schema{
"document_root": {
Type: schema.TypeString,
Optional: true,
//Default: "public",
},
"rails_env": &schema.Schema{
"rails_env": {
Type: schema.TypeString,
Optional: true,
//Default: "production",
},
"auto_bundle_on_deploy": &schema.Schema{
"auto_bundle_on_deploy": {
Type: schema.TypeString,
Optional: true,
//Default: true,
},
"aws_flow_ruby_settings": &schema.Schema{
"aws_flow_ruby_settings": {
Type: schema.TypeString,
Optional: true,
},
"app_source": &schema.Schema{
"app_source": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"type": &schema.Schema{
"type": {
Type: schema.TypeString,
Required: true,
},

"url": &schema.Schema{
"url": {
Type: schema.TypeString,
Optional: true,
},

"username": &schema.Schema{
"username": {
Type: schema.TypeString,
Optional: true,
},

"password": &schema.Schema{
"password": {
Type: schema.TypeString,
Optional: true,
},

"revision": &schema.Schema{
"revision": {
Type: schema.TypeString,
Optional: true,
},

"ssh_key": &schema.Schema{
"ssh_key": {
Type: schema.TypeString,
Optional: true,
},
Expand All @@ -121,60 +121,60 @@ func resourceAwsOpsworksApplication() *schema.Resource {
// AutoSelectOpsworksMysqlInstance, OpsworksMysqlInstance, or RdsDbInstance.
// anything beside auto select will lead into failure in case the instance doesn't exist
// XXX: validation?
"data_source_type": &schema.Schema{
"data_source_type": {
Type: schema.TypeString,
Optional: true,
},
"data_source_database_name": &schema.Schema{
"data_source_database_name": {
Type: schema.TypeString,
Optional: true,
},
"data_source_arn": &schema.Schema{
"data_source_arn": {
Type: schema.TypeString,
Optional: true,
},
"description": &schema.Schema{
"description": {
Type: schema.TypeString,
Optional: true,
},
"domains": &schema.Schema{
"domains": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"environment": &schema.Schema{
"environment": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"key": &schema.Schema{
"key": {
Type: schema.TypeString,
Required: true,
},
"value": &schema.Schema{
"value": {
Type: schema.TypeString,
Required: true,
},
"secure": &schema.Schema{
"secure": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},
},
},
},
"enable_ssl": &schema.Schema{
"enable_ssl": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"ssl_configuration": &schema.Schema{
"ssl_configuration": {
Type: schema.TypeList,
Optional: true,
//Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"certificate": &schema.Schema{
"certificate": {
Type: schema.TypeString,
Required: true,
StateFunc: func(v interface{}) string {
Expand All @@ -186,7 +186,7 @@ func resourceAwsOpsworksApplication() *schema.Resource {
}
},
},
"private_key": &schema.Schema{
"private_key": {
Type: schema.TypeString,
Required: true,
StateFunc: func(v interface{}) string {
Expand All @@ -198,7 +198,7 @@ func resourceAwsOpsworksApplication() *schema.Resource {
}
},
},
"chain": &schema.Schema{
"chain": {
Type: schema.TypeString,
Optional: true,
StateFunc: func(v interface{}) string {
Expand Down
10 changes: 5 additions & 5 deletions builtin/providers/aws/resource_aws_opsworks_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestAccAWSOpsworksApplication(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckAwsOpsworksApplicationDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testAccAwsOpsworksApplicationCreate(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSOpsworksApplicationExists(
Expand Down Expand Up @@ -62,7 +62,7 @@ func TestAccAWSOpsworksApplication(t *testing.T) {
),
),
},
resource.TestStep{
{
Config: testAccAwsOpsworksApplicationUpdate(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSOpsworksApplicationExists(
Expand Down Expand Up @@ -193,7 +193,7 @@ func testAccCheckAWSOpsworksCreateAppAttributes(
}

expectedEnv := []*opsworks.EnvironmentVariable{
&opsworks.EnvironmentVariable{
{
Key: aws.String("key1"),
Value: aws.String("value1"),
Secure: aws.Bool(false),
Expand Down Expand Up @@ -253,12 +253,12 @@ func testAccCheckAWSOpsworksUpdateAppAttributes(
}

expectedEnv := []*opsworks.EnvironmentVariable{
&opsworks.EnvironmentVariable{
{
Key: aws.String("key2"),
Value: aws.String("*****FILTERED*****"),
Secure: aws.Bool(true),
},
&opsworks.EnvironmentVariable{
{
Key: aws.String("key1"),
Value: aws.String("value1"),
Secure: aws.Bool(false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestAccAWSOpsworksCustomLayer(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckAwsOpsworksCustomLayerDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testAccAwsOpsworksCustomLayerConfigNoVpcCreate(stackName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSOpsworksCustomLayerExists(
Expand Down Expand Up @@ -74,7 +74,7 @@ func TestAccAWSOpsworksCustomLayer(t *testing.T) {
),
),
},
resource.TestStep{
{
Config: testAccAwsOpsworksCustomLayerConfigUpdate(stackName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -219,7 +219,7 @@ func testAccCheckAWSOpsworksCreateLayerAttributes(
}

expectedEbsVolumes := []*opsworks.VolumeConfiguration{
&opsworks.VolumeConfiguration{
{
VolumeType: aws.String("gp2"),
NumberOfDisks: aws.Int64(2),
MountPoint: aws.String("/home"),
Expand Down
6 changes: 3 additions & 3 deletions builtin/providers/aws/resource_aws_opsworks_ganglia_layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ func resourceAwsOpsworksGangliaLayer() *schema.Resource {
DefaultLayerName: "Ganglia",

Attributes: map[string]*opsworksLayerTypeAttribute{
"url": &opsworksLayerTypeAttribute{
"url": {
AttrName: "GangliaUrl",
Type: schema.TypeString,
Default: "/ganglia",
},
"username": &opsworksLayerTypeAttribute{
"username": {
AttrName: "GangliaUser",
Type: schema.TypeString,
Default: "opsworks",
},
"password": &opsworksLayerTypeAttribute{
"password": {
AttrName: "GangliaPassword",
Type: schema.TypeString,
Required: true,
Expand Down
12 changes: 6 additions & 6 deletions builtin/providers/aws/resource_aws_opsworks_haproxy_layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@ func resourceAwsOpsworksHaproxyLayer() *schema.Resource {
DefaultLayerName: "HAProxy",

Attributes: map[string]*opsworksLayerTypeAttribute{
"stats_enabled": &opsworksLayerTypeAttribute{
"stats_enabled": {
AttrName: "EnableHaproxyStats",
Type: schema.TypeBool,
Default: true,
},
"stats_url": &opsworksLayerTypeAttribute{
"stats_url": {
AttrName: "HaproxyStatsUrl",
Type: schema.TypeString,
Default: "/haproxy?stats",
},
"stats_user": &opsworksLayerTypeAttribute{
"stats_user": {
AttrName: "HaproxyStatsUser",
Type: schema.TypeString,
Default: "opsworks",
},
"stats_password": &opsworksLayerTypeAttribute{
"stats_password": {
AttrName: "HaproxyStatsPassword",
Type: schema.TypeString,
WriteOnly: true,
Required: true,
},
"healthcheck_url": &opsworksLayerTypeAttribute{
"healthcheck_url": {
AttrName: "HaproxyHealthCheckUrl",
Type: schema.TypeString,
Default: "/",
},
"healthcheck_method": &opsworksLayerTypeAttribute{
"healthcheck_method": {
AttrName: "HaproxyHealthCheckMethod",
Type: schema.TypeString,
Default: "OPTIONS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestAccAWSOpsworksInstance(t *testing.T) {
"aws_opsworks_instance.tf-acc", "tenancy", "default",
),
resource.TestCheckResourceAttr(
"aws_opsworks_instance.tf-acc", "os", "Amazon Linux 2014.09", // inherited from opsworks_stack_test
"aws_opsworks_instance.tf-acc", "os", "Amazon Linux 2016.09", // inherited from opsworks_stack_test
),
resource.TestCheckResourceAttr(
"aws_opsworks_instance.tf-acc", "root_device_type", "ebs", // inherited from opsworks_stack_test
Expand Down
10 changes: 5 additions & 5 deletions builtin/providers/aws/resource_aws_opsworks_java_app_layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ func resourceAwsOpsworksJavaAppLayer() *schema.Resource {
DefaultLayerName: "Java App Server",

Attributes: map[string]*opsworksLayerTypeAttribute{
"jvm_type": &opsworksLayerTypeAttribute{
"jvm_type": {
AttrName: "Jvm",
Type: schema.TypeString,
Default: "openjdk",
},
"jvm_version": &opsworksLayerTypeAttribute{
"jvm_version": {
AttrName: "JvmVersion",
Type: schema.TypeString,
Default: "7",
},
"jvm_options": &opsworksLayerTypeAttribute{
"jvm_options": {
AttrName: "JvmOptions",
Type: schema.TypeString,
Default: "",
},
"app_server": &opsworksLayerTypeAttribute{
"app_server": {
AttrName: "JavaAppServer",
Type: schema.TypeString,
Default: "tomcat",
},
"app_server_version": &opsworksLayerTypeAttribute{
"app_server_version": {
AttrName: "JavaAppServerVersion",
Type: schema.TypeString,
Default: "7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func resourceAwsOpsworksMemcachedLayer() *schema.Resource {
DefaultLayerName: "Memcached",

Attributes: map[string]*opsworksLayerTypeAttribute{
"allocated_memory": &opsworksLayerTypeAttribute{
"allocated_memory": {
AttrName: "MemcachedMemory",
Type: schema.TypeInt,
Default: 512,
Expand Down
4 changes: 2 additions & 2 deletions builtin/providers/aws/resource_aws_opsworks_mysql_layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ func resourceAwsOpsworksMysqlLayer() *schema.Resource {
DefaultLayerName: "MySQL",

Attributes: map[string]*opsworksLayerTypeAttribute{
"root_password": &opsworksLayerTypeAttribute{
"root_password": {
AttrName: "MysqlRootPassword",
Type: schema.TypeString,
WriteOnly: true,
},
"root_password_on_all_instances": &opsworksLayerTypeAttribute{
"root_password_on_all_instances": {
AttrName: "MysqlRootPasswordUbiquitous",
Type: schema.TypeBool,
Default: true,
Expand Down
Loading

0 comments on commit 4f58099

Please sign in to comment.