diff --git a/builtin/providers/aws/resource_aws_opsworks_custom_layer_test.go b/builtin/providers/aws/resource_aws_opsworks_custom_layer_test.go index 14a65b106..a39b5dbdb 100644 --- a/builtin/providers/aws/resource_aws_opsworks_custom_layer_test.go +++ b/builtin/providers/aws/resource_aws_opsworks_custom_layer_test.go @@ -12,16 +12,13 @@ import ( // and `aws-opsworks-service-role`. func TestAccAwsOpsworksCustomLayer(t *testing.T) { - opsiam := testAccAwsOpsworksStackIam{} - testAccAwsOpsworksStackPopulateIam(t, &opsiam) - resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAwsOpsworksCustomLayerDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: fmt.Sprintf(testAccAwsOpsworksCustomLayerConfigCreate, opsiam.ServiceRoleArn, opsiam.InstanceProfileArn), + Config: testAccAwsOpsworksCustomLayerConfigCreate, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "aws_opsworks_custom_layer.tf-acc", "name", "tf-ops-acc-custom-layer", @@ -68,7 +65,7 @@ func TestAccAwsOpsworksCustomLayer(t *testing.T) { ), }, resource.TestStep{ - Config: fmt.Sprintf(testAccAwsOpsworksCustomLayerConfigUpdate, opsiam.ServiceRoleArn, opsiam.InstanceProfileArn), + Config: testAccAwsOpsworksCustomLayerConfigUpdate, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "aws_opsworks_custom_layer.tf-acc", "name", "tf-ops-acc-custom-layer", diff --git a/builtin/providers/aws/resource_aws_opsworks_stack_test.go b/builtin/providers/aws/resource_aws_opsworks_stack_test.go index 2a3e95b3c..63a27578c 100644 --- a/builtin/providers/aws/resource_aws_opsworks_stack_test.go +++ b/builtin/providers/aws/resource_aws_opsworks_stack_test.go @@ -8,23 +8,91 @@ import ( "github.com/hashicorp/terraform/terraform" "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/iam" "github.com/aws/aws-sdk-go/service/opsworks" ) -// These tests assume the existence of predefined Opsworks IAM roles named `aws-opsworks-ec2-role` -// and `aws-opsworks-service-role`. +////////////////////////////////////////////////// +//// Helper configs for the necessary IAM objects +////////////////////////////////////////////////// + +var testAccAwsOpsworksStackIamConfig = ` +resource "aws_iam_role" "opsworks_service" { + name = "terraform_testacc_opsworks_service" + assume_role_policy = <