diff --git a/aws/resource_aws_emr_cluster.go b/aws/resource_aws_emr_cluster.go index 06e380b8bbd..a9b205cda88 100644 --- a/aws/resource_aws_emr_cluster.go +++ b/aws/resource_aws_emr_cluster.go @@ -133,11 +133,13 @@ func resourceAwsEMRCluster() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, + Computed: true, }, "emr_managed_slave_security_group": { Type: schema.TypeString, Optional: true, ForceNew: true, + Computed: true, }, "instance_profile": { Type: schema.TypeString, @@ -148,6 +150,7 @@ func resourceAwsEMRCluster() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, + Computed: true, }, }, }, diff --git a/aws/resource_aws_emr_cluster_test.go b/aws/resource_aws_emr_cluster_test.go index ab60c887da7..8257f2c2147 100644 --- a/aws/resource_aws_emr_cluster_test.go +++ b/aws/resource_aws_emr_cluster_test.go @@ -5034,3 +5034,261 @@ data "aws_ami" "emr-custom-ami" { } `, r, r, r, r, r, r, r, r) } + +func TestAccAWSEMRCluster_defaultRoles(t *testing.T) { + var cluster emr.Cluster + rInt := acctest.RandInt() + resourceName := "aws_emr_cluster.tf-test-cluster" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSEmrDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSEmrClusterConfig_defaultRoles(rInt), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSEmrClusterExists(resourceName, &cluster), + ), + }, + }, + }) +} + +func testAccAWSEmrClusterConfig_defaultRoles(r int) string { + return fmt.Sprintf(` + resource "aws_vpc" "vpc" { + cidr_block = "10.0.0.0/16" + } + + resource "aws_emr_cluster" "tf-test-cluster" { + name = "emr-test-%[1]d" + release_label = "emr-4.6.0" + applications = ["Spark"] + + ec2_attributes { + subnet_id = "${aws_subnet.main.id}" + instance_profile = "${aws_iam_instance_profile.emr_profile.arn}" + } + + master_instance_type = "c4.large" + core_instance_type = "c4.large" + core_instance_count = 1 + + tags { + role = "rolename" + dns_zone = "env_zone" + env = "env" + name = "name-env" + } + + termination_protection = false + + configurations = "test-fixtures/emr_configurations.json" + + depends_on = ["aws_main_route_table_association.a"] + + service_role = "${aws_iam_role.iam_emr_default_role.arn}" + //ebs_root_volume_size = 21 + } + + resource "aws_subnet" "main" { + vpc_id = "${aws_vpc.vpc.id}" + cidr_block = "10.0.0.0/24" + + tags { + Name = "tf-acc-emr-cluster" + } + } + + + resource "aws_internet_gateway" "gw" { + vpc_id = "${aws_vpc.vpc.id}" + } + + resource "aws_route_table" "r" { + vpc_id = "${aws_vpc.vpc.id}" + + route { + cidr_block = "0.0.0.0/0" + gateway_id = "${aws_internet_gateway.gw.id}" + } + } + + resource "aws_main_route_table_association" "a" { + vpc_id = "${aws_vpc.vpc.id}" + route_table_id = "${aws_route_table.r.id}" + } + + ### + + # IAM things + + ### + + # IAM role for EMR Service + resource "aws_iam_role" "iam_emr_default_role" { + name = "iam_emr_default_role-%[1]d" + + assume_role_policy = <