localstack / localstack/aws-cdk-local

Potentially cached values in cdk.context.json can break deployments

Open
#67 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

awaiting-response
Dominant language
JavaScript
Stars
305
Forks
18
PR merge metrics
No merged PRs in 30d

Description

Seems like CDK is caching values in cdk.context.json that are not always updated on cdk bootstrap or cdk deploy.

For example, just ran into a case where cdk.context.json contained cached local VPC/subnet details:

{
  "vpc-provider:account=000000000000:filter.isDefault=true:region=us-east-1:returnAsymmetricSubnets=true": {
    "vpcId": "vpc-69bd3613",
    "vpcCidrBlock": "172.31.0.0/16",
    "availabilityZones": [],
    "subnetGroups": [
      {
        "name": "Public",
        "type": "Public",
        "subnets": [
          {
            "subnetId": "subnet-47b445b3",
            "cidr": "172.31.0.0/20",
            "availabilityZone": "us-east-1a",
            "routeTableId": "rtb-b807fb5a"
          },
          {
            "subnetId": "subnet-99289971",
            "cidr": "172.31.16.0/20",
            "availabilityZone": "us-east-1b",
            "routeTableId": "rtb-b807fb5a"
          },
  ...

... and upon deployment of an AWS::RDS::DBSubnetGroup resource that was referencing one of the subnets, the deployment failed, as this subnet was no longer returned from awslocal ec2 describe-subnets (double-checked that the region was correct).

botocore.exceptions.ClientError: An error occurred (InvalidSubnetID.NotFound) when calling the CreateDBSubnetGroup operation: The subnet ID 'subnet-47b445b3' does not exist

We should consider deleting the cdk.context.json cache file (or updating its entries) on cdklocal bootstrap and/or cdklocal deploy, to ensure we're not using stale entries for deployment..

/cc @dominikschubert

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how cdklocal bootstrap and cdklocal deploy handle cdk.context.json, then reproduce the stale-subnet case with awslocal ec2 describe-subnets. Check whether cached VPC and subnet entries are reused during deployment; done means deployments no longer reference subnet IDs that the configured environment does not return.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.