diff --git a/aws/resource_aws_ecs_task_definition.go b/aws/resource_aws_ecs_task_definition.go index 6ffd916dcb1..f58a4f5ab46 100644 --- a/aws/resource_aws_ecs_task_definition.go +++ b/aws/resource_aws_ecs_task_definition.go @@ -188,6 +188,27 @@ func resourceAwsEcsTaskDefinition() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, }, + "ipc_mode": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + ecs.IpcModeHost, + ecs.IpcModeNone, + ecs.IpcModeTask, + }, false), + }, + + "pid_mode": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + ecs.PidModeHost, + ecs.PidModeTask, + }, false), + }, + "tags": tagsSchema(), }, } @@ -241,6 +262,14 @@ func resourceAwsEcsTaskDefinitionCreate(d *schema.ResourceData, meta interface{} input.NetworkMode = aws.String(v.(string)) } + if v, ok := d.GetOk("ipc_mode"); ok { + input.IpcMode = aws.String(v.(string)) + } + + if v, ok := d.GetOk("pid_mode"); ok { + input.PidMode = aws.String(v.(string)) + } + if v, ok := d.GetOk("volume"); ok { volumes, err := expandEcsVolumes(v.(*schema.Set).List()) if err != nil { diff --git a/aws/resource_aws_ecs_task_definition_test.go b/aws/resource_aws_ecs_task_definition_test.go index 1a9e43176e8..6a0872dc20b 100644 --- a/aws/resource_aws_ecs_task_definition_test.go +++ b/aws/resource_aws_ecs_task_definition_test.go @@ -243,6 +243,56 @@ func TestAccAWSEcsTaskDefinition_withNetworkMode(t *testing.T) { }) } +func TestAccAWSEcsTaskDefinition_withIPCMode(t *testing.T) { + var def ecs.TaskDefinition + + rString := acctest.RandString(8) + roleName := fmt.Sprintf("tf_acc_ecs_td_with_ipc_mode_%s", rString) + policyName := fmt.Sprintf("tf_acc_ecs_td_with_ipc_mode_%s", rString) + tdName := fmt.Sprintf("tf_acc_td_with_ipc_mode_%s", rString) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSEcsTaskDefinitionDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSEcsTaskDefinitionWithIpcMode(roleName, policyName, tdName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSEcsTaskDefinitionExists("aws_ecs_task_definition.sleep", &def), + resource.TestCheckResourceAttr( + "aws_ecs_task_definition.sleep", "ipc_mode", "host"), + ), + }, + }, + }) +} + +func TestAccAWSEcsTaskDefinition_withPidMode(t *testing.T) { + var def ecs.TaskDefinition + + rString := acctest.RandString(8) + roleName := fmt.Sprintf("tf_acc_ecs_td_with_pid_mode_%s", rString) + policyName := fmt.Sprintf("tf_acc_ecs_td_with_pid_mode_%s", rString) + tdName := fmt.Sprintf("tf_acc_td_with_pid_mode_%s", rString) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSEcsTaskDefinitionDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSEcsTaskDefinitionWithPidMode(roleName, policyName, tdName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSEcsTaskDefinitionExists("aws_ecs_task_definition.sleep", &def), + resource.TestCheckResourceAttr( + "aws_ecs_task_definition.sleep", "pid_mode", "host"), + ), + }, + }, + }) +} + func TestAccAWSEcsTaskDefinition_constraint(t *testing.T) { var def ecs.TaskDefinition @@ -1083,6 +1133,138 @@ TASK_DEFINITION }`, roleName, policyName, tdName) } +func testAccAWSEcsTaskDefinitionWithIpcMode(roleName, policyName, tdName string) string { + return fmt.Sprintf(` + resource "aws_iam_role" "role_test" { + name = "%s" + path = "/test/" + assume_role_policy = <