Skip to content

Commit

Permalink
Add credentials_parameter to task definition
Browse files Browse the repository at this point in the history
  • Loading branch information
allisaurus committed Aug 2, 2018
1 parent 1f8c534 commit 681a036
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
8 changes: 8 additions & 0 deletions ecs-cli/modules/utils/compose/convert_task_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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")
}
}

Expand Down
5 changes: 1 addition & 4 deletions ecs-cli/modules/utils/compose/ecs_params_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/aws/aws-sdk-go/service/ecs"
libYaml "github.com/docker/libcompose/yaml"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
)

Expand Down Expand Up @@ -74,7 +73,7 @@ type HealthCheck struct {

// RepositoryCredentials holds CredentialParameters for a ContainerDef
type RepositoryCredentials struct {
CredentialsParameter string `yaml:"credentials_param"`
CredentialsParameter string `yaml:"credentials_parameter"`
}

// TaskSize holds Cpu and Memory values needed for Fargate tasks
Expand Down Expand Up @@ -209,8 +208,6 @@ func ReadECSParams(filename string) (*ECSParams, error) {
return nil, errors.Wrapf(err, "Error unmarshalling yaml data from ECS params file: %v", filename)
}

log.Infof("ECS params: %+v", ecsParams) // remove me!

return ecsParams, nil
}

Expand Down
4 changes: 2 additions & 2 deletions ecs-cli/modules/utils/compose/ecs_params_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ task_definition:
wordpress:
essential: true
repository_credentials:
credentials_param: arn:aws:secretsmanager:1234567890:secret:test-RT4iv`
credentials_parameter: arn:aws:secretsmanager:1234567890:secret:test-RT4iv`

content := []byte(ecsParamsString)

Expand Down Expand Up @@ -119,7 +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, wordpress.RepositoryCredentials.CredentialsParameter, "arn:aws:secretsmanager:1234567890:secret:test-RT4iv")
assert.Equal(t, "arn:aws:secretsmanager:1234567890:secret:test-RT4iv", wordpress.RepositoryCredentials.CredentialsParameter, "Expected CredentialsParameter to match")
}
}

Expand Down

0 comments on commit 681a036

Please sign in to comment.