diff --git a/ecs-cli/modules/utils/compose/convert_task_definition.go b/ecs-cli/modules/utils/compose/convert_task_definition.go index 162a62abb..aa9afa165 100644 --- a/ecs-cli/modules/utils/compose/convert_task_definition.go +++ b/ecs-cli/modules/utils/compose/convert_task_definition.go @@ -175,8 +175,16 @@ func convertToContainerDef(inputCfg *adapter.ContainerConfig, ecsContainerDef *C mem = resolveIntResourceOverride(inputCfg.Name, mem, ecsMemInMB, "MemoryLimit") ecsMemResInMB := adapter.ConvertToMemoryInMB(int64(ecsContainerDef.MemoryReservation)) + memRes = resolveIntResourceOverride(inputCfg.Name, memRes, ecsMemResInMB, "MemoryReservation") + credParam := ecsContainerDef.RepositoryCredentials.CredentialsParameter + + if credParam != "" { + outputContDef.RepositoryCredentials = &ecs.RepositoryCredentials{} + outputContDef.RepositoryCredentials.SetCredentialsParameter(credParam) + } + var err error healthCheck, err = resolveHealthCheck(inputCfg.Name, healthCheck, ecsContainerDef.HealthCheck) if err != nil { diff --git a/ecs-cli/modules/utils/compose/convert_task_definition_test.go b/ecs-cli/modules/utils/compose/convert_task_definition_test.go index 79d279681..3254b1748 100644 --- a/ecs-cli/modules/utils/compose/convert_task_definition_test.go +++ b/ecs-cli/modules/utils/compose/convert_task_definition_test.go @@ -436,6 +436,8 @@ task_definition: services: mysql: essential: false + repository_credentials: + credentials_parameter: arn:aws:secretsmanager:1234567890:secret:test-secret task_size: mem_limit: 5Gb cpu_limit: 256` @@ -471,7 +473,7 @@ task_definition: assert.Equal(t, "256", aws.StringValue(taskDefinition.Cpu), "Expected CPU to match") assert.Equal(t, "5Gb", aws.StringValue(taskDefinition.Memory), "Expected CPU to match") assert.True(t, aws.BoolValue(wordpress.Essential), "Expected container with name: '%v' to be true", *wordpress.Name) - + assert.Equal(t, "arn:aws:secretsmanager:1234567890:secret:test-secret", aws.StringValue(mysql.RepositoryCredentials.CredentialsParameter), "Expected CredentialsParameter to match") } } diff --git a/ecs-cli/modules/utils/compose/ecs_params_reader.go b/ecs-cli/modules/utils/compose/ecs_params_reader.go index a30d67132..74c44276f 100644 --- a/ecs-cli/modules/utils/compose/ecs_params_reader.go +++ b/ecs-cli/modules/utils/compose/ecs_params_reader.go @@ -51,7 +51,8 @@ type ContainerDefs map[string]ContainerDef // ContainerDef holds fields for an ECS Container Definition that are not supplied by docker-compose type ContainerDef struct { - Essential bool `yaml:"essential"` + Essential bool `yaml:"essential"` + RepositoryCredentials RepositoryCredentials `yaml:"repository_credentials"` // resource field yaml names correspond to equivalent docker-compose field Cpu int64 `yaml:"cpu_shares"` Memory libYaml.MemStringorInt `yaml:"mem_limit"` @@ -70,6 +71,11 @@ type HealthCheck struct { StartPeriod string `yaml:"start_period,omitempty"` } +// RepositoryCredentials holds CredentialParameters for a ContainerDef +type RepositoryCredentials struct { + CredentialsParameter string `yaml:"credentials_parameter"` +} + // TaskSize holds Cpu and Memory values needed for Fargate tasks // https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html type TaskSize struct { diff --git a/ecs-cli/modules/utils/compose/ecs_params_reader_test.go b/ecs-cli/modules/utils/compose/ecs_params_reader_test.go index 2d1ab2de8..2b29f7deb 100644 --- a/ecs-cli/modules/utils/compose/ecs_params_reader_test.go +++ b/ecs-cli/modules/utils/compose/ecs_params_reader_test.go @@ -83,7 +83,9 @@ task_definition: mem_limit: 524288000 mem_reservation: 500mb wordpress: - essential: true` + essential: true + repository_credentials: + credentials_parameter: arn:aws:secretsmanager:1234567890:secret:test-RT4iv` content := []byte(ecsParamsString) @@ -117,6 +119,7 @@ task_definition: assert.Equal(t, yaml.MemStringorInt(524288000), mysql.Memory) assert.Equal(t, yaml.MemStringorInt(524288000), mysql.MemoryReservation) assert.True(t, wordpress.Essential, "Expected container to be essential") + assert.Equal(t, "arn:aws:secretsmanager:1234567890:secret:test-RT4iv", wordpress.RepositoryCredentials.CredentialsParameter, "Expected CredentialsParameter to match") } }