Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue causing missing api gateway tags on first deploy #550

Merged
merged 1 commit into from
Jan 11, 2024
Merged
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
17 changes: 15 additions & 2 deletions cloud/aws/deploy/api/apigateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ func NewAwsApiGateway(ctx *pulumi.Context, name string, args *AwsApiGatewayArgs,
}))
}

apiGatewayTags := common.Tags(args.StackID, name, resources.API)

doc := pulumi.All(nameArnPairs...).ApplyT(func(pairs []interface{}) (string, error) {
naps := make(map[string]string)

Expand All @@ -123,6 +125,15 @@ func NewAwsApiGateway(ctx *pulumi.Context, name string, args *AwsApiGatewayArgs,
args.OpenAPISpec.Paths[k] = p
}

// Important: AWS will use these on the first deployment, but not subsequent updates
// subsequent updates use the tags provided to Pulumi below.
for n, v := range apiGatewayTags {
args.OpenAPISpec.Tags = append(args.OpenAPISpec.Tags, &openapi3.Tag{
Name: n,
Extensions: map[string]interface{}{"x-amazon-apigateway-tag-value": v},
})
}

// augment the api specs with security definitions where available
b, err := json.Marshal(args.OpenAPISpec)
if err != nil {
Expand All @@ -133,9 +144,11 @@ func NewAwsApiGateway(ctx *pulumi.Context, name string, args *AwsApiGatewayArgs,
}).(pulumi.StringOutput)

res.Api, err = apigatewayv2.NewApi(ctx, name, &apigatewayv2.ApiArgs{
Body: doc,
Body: doc,
// Name fixed to title in the spec, if these mismatch the name will change on the second deployment.
Name: pulumi.String(args.OpenAPISpec.Info.Title),
ProtocolType: pulumi.String("HTTP"),
Tags: pulumi.ToStringMap(common.Tags(args.StackID, name, resources.API)),
Tags: pulumi.ToStringMap(apiGatewayTags),
FailOnWarnings: pulumi.Bool(true),
}, opts...)
if err != nil {
Expand Down
Loading