Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

ADDS Support to define IAM roles in yml by ARN #1506

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/ecs-compose-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ services:
Resource: arn:aws:sqs:us-east-1:12345678:myqueue
```

Use an existing IAM role to a task:

NOTE: This will override any as above mentioned in-line IAM policys.
```yaml
services:
test:
x-aws-iam: arn:aws:iam::123456789:role/applicationTaskRole
```

###### Logging
Pass options to awslogs driver
```yaml
Expand Down
15 changes: 10 additions & 5 deletions ecs/cloudformation.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,21 @@ func (b *ecsAPIService) convert(ctx context.Context, project *types.Project) (*c
}

func (b *ecsAPIService) createService(project *types.Project, service types.ServiceConfig, template *cloudformation.Template, resources awsResources) error {
taskExecutionRole := b.createTaskExecutionRole(project, service, template)
taskRole := b.createTaskRole(project, service, template, resources)

definition, err := b.createTaskDefinition(project, service, resources)
if err != nil {
return err
}

taskExecutionRole := b.createTaskExecutionRole(project, service, template)
definition.ExecutionRoleArn = cloudformation.Ref(taskExecutionRole)
if taskRole != "" {
definition.TaskRoleArn = cloudformation.Ref(taskRole)

if taskRoleArn, ok := service.Extensions[extensionIam]; ok {
definition.TaskRoleArn = fmt.Sprintf("%s", taskRoleArn)
} else {
taskRole := b.createTaskRole(project, service, template, resources)
if taskRole != "" {
definition.TaskRoleArn = cloudformation.Ref(taskRole)
}
}

taskDefinition := fmt.Sprintf("%sTaskDefinition", normalizeResourceName(service.Name))
Expand Down
1 change: 1 addition & 0 deletions ecs/x.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const (
extensionMaxPercent = "x-aws-max_percent"
extensionRetention = "x-aws-logs_retention"
extensionRole = "x-aws-role"
extensionIam = "x-aws-iam"
extensionManagedPolicies = "x-aws-policies"
extensionAutoScaling = "x-aws-autoscaling"
extensionCloudFormation = "x-aws-cloudformation"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ require (
github.com/valyala/fasttemplate v1.2.1 // indirect
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4
golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54
google.golang.org/grpc v1.33.2
google.golang.org/protobuf v1.25.0
gopkg.in/ini.v1 v1.62.0
Expand Down