aws api-gateway - cdk stage deployment setup - updating without drift

Viewed 282

I want to setup an api gateway using cdk - with RestApi, Resource, Method and Stage - all included in the cdk stack.

To create the Stage construct in the cdk stack, it required a Deployment, so I defined this in the cdk stack.

deployment = apigateway_v1.Deployment(self, "Deployment", api=rest_api)

stage = apigateway_v1.Stage(
    self, 
    "test",
    deployment=deployment,
    stage_name="test"
)

However, when I later make a change to the Resource Method definition - and re-deploy the cdk stack, the api-gateway is not updating. So I end up either redeploying the api-gateway either via the aws console or the aws-cli create-deployment

But now when I check for cloudformation stack drift, it shows the Stage has drifted.

How can I prevent stack drift while keeping the Stage in the cdk stack?

1 Answers
Related