If in case you have an AWS API Gateway useful resource, and wish it to pressure a redeployment utilizing CloudFormation, then you should use the TIMESTAMP
trick.
template.yaml
extract:
APIGatewayStage:
Kind: AWS::ApiGateway::Stage
Properties:
StageName: !Sub ${EnvironmentTagName}
RestApiId: !Ref APIGateway
DeploymentId: !Ref APIGatewayDeployment__TIMESTAMP__
TracingEnabled: true
MethodSettings:
- DataTraceEnabled: true
HttpMethod: "*"
LoggingLevel: INFO
ResourcePath: "/*"
MetricsEnabled: true
APIGatewayDeployment__TIMESTAMP__:
Kind: AWS::ApiGateway::Deployment
Properties:
RestApiId: !Ref APIGateway
Description: !Sub ${EnvironmentTagName} Deployment __TIMESTAMP__
APIGateway:
Kind: AWS::ApiGateway::RestApi
Properties:
Title: !Ref "AWS::StackName"
...
As we are able to see, on line 15 above, we use the __TIMESTAMP__
string within the APIGatewayDeployment
stage.
Now we merely make sure that to replace the template.yaml
file with our CI run, changing the occurence of __TIMESTAMP__
with the TIMESTAMP
variable generated:
TIMESTAMP="$(date +%s)"
sed -i "s/__TIMESTAMP__/${TIMESTAMP}/g" template.yaml