diff --git a/provider/aws/processes.go b/provider/aws/processes.go index b162df036..b94f143b3 100644 --- a/provider/aws/processes.go +++ b/provider/aws/processes.go @@ -13,6 +13,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/service/cloudformation" "github.com/aws/aws-sdk-go/service/dynamodb" "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ecs" @@ -1091,7 +1092,7 @@ func (p *Provider) generateTaskDefinition2(app, service string, opts structs.Pro } aps := stackParameters(as) - aos := stackOutputs(as) + // aos := stackOutputs(as) senv := s.EnvironmentDefaults() @@ -1123,10 +1124,10 @@ func (p *Provider) generateTaskDefinition2(app, service string, opts structs.Pro return nil, err } - ResourceEnvVariables := map[string]string{"URL":"Url","NAME":"Name","HOST":"Host","PASS":"Pass","PORT":"Port","USER":"User"} + ResourceEnvVariables := map[string]string{"URL": "Url", "NAME": "Name", "HOST": "Host", "PASS": "Pass", "PORT": "Port", "USER": "User"} ResourceName := strings.Replace(strings.ToUpper(r), "-", "_", -1) - for k,v := range ResourceEnvVariables{ + for k, v := range ResourceEnvVariables { senv[fmt.Sprintf("%s_%s", ResourceName, k)] = stackOutputs(rs)[v] } } @@ -1191,10 +1192,32 @@ func (p *Provider) generateTaskDefinition2(app, service string, opts structs.Pro } } + td, err := p.stackResource(fmt.Sprintf("%s-%s", p.Rack, app), "ServiceWeb") + if err != nil { + return nil, err + } + + nestedStackID := td.PhysicalResourceId + + describeStackOutput, err := p.cloudformation().DescribeStacks(&cloudformation.DescribeStacksInput{ + StackName: nestedStackID, + }) + if err != nil { + return nil, err + } + + nestedStackName := describeStackOutput.Stacks[0].StackName + + ts, err := p.stackResource(*nestedStackName, "DedicatedRole") + if err != nil { + return nil, err + } + req := &ecs.RegisterTaskDefinitionInput{ ContainerDefinitions: []*ecs.ContainerDefinition{cd}, Family: aws.String(fmt.Sprintf("%s-%s-%s", p.Rack, app, service)), - TaskRoleArn: aws.String(aos["ServiceRole"]), + // TaskRoleArn: aws.String(aos["ServiceRole"]), + TaskRoleArn: aws.String(*ts.PhysicalResourceId), Volumes: vs, }