Skip to content

Commit

Permalink
updated task definition generate function
Browse files Browse the repository at this point in the history
  • Loading branch information
numcys committed Oct 23, 2024
1 parent 1aedb67 commit f18ed3e
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions provider/aws/processes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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]
}
}
Expand Down Expand Up @@ -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,
}

Expand Down

0 comments on commit f18ed3e

Please sign in to comment.