Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
When you’ve got an AWS API Gateway useful resource, and want it to pressure a redeployment utilizing CloudFormation, then you should use the TIMESTAMP
trick.
template.yaml
extract:
APIGatewayStage:
Sort: 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__:
Sort: AWS::ApiGateway::Deployment
Properties:
RestApiId: !Ref APIGateway
Description: !Sub ${EnvironmentTagName} Deployment __TIMESTAMP__
APIGateway:
Sort: AWS::ApiGateway::RestApi
Properties:
Identify: !Ref "AWS::StackName"
...
As we will see, on line 15 above, we use the __TIMESTAMP__
string within the APIGatewayDeployment
stage.
Now we merely ensure 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