Skip to content

Commit 27d495f

Browse files
authored
fix: add --import-existing-resources to CDK deploy in integration-suite (#1174)
## What changed and why Added `--import-existing-resources` flag to the `npx cdk deploy` command in the `integration-suite` CI job (`.gitlab/templates/pipeline.yaml.tpl`). **Root cause**: When a pipeline fails mid-deploy, some AWS resources (specifically the dotnet Lambda log group `/aws/lambda/integ-{IDENTIFIER}-{TEST_SUITE}-dotnet-lambda`) are created in AWS but the CloudFormation stack is left in `ROLLBACK_COMPLETE` state. On a pipeline retry for the same commit (same `IDENTIFIER` = `CI_COMMIT_SHORT_SHA`), CDK attempts to create the already-existing log group and fails with: ``` ToolkitError: ChangeSet 'cdk-deploy-change-set' on stack 'integ-{IDENTIFIER}-{TEST_SUITE}' failed early validation: - Resource of type 'AWS::Logs::LogGroup' with identifier '/aws/lambda/integ-{IDENTIFIER}-{TEST_SUITE}-dotnet-lambda' already exists. ``` The `--import-existing-resources` flag tells CDK to import any already-existing resources into the stack instead of failing validation, which is the standard CDK solution for this exact scenario. ## Jira [SVLS-8825](https://datadoghq.atlassian.net/browse/SVLS-8825) [SVLS-8825]: https://datadoghq.atlassian.net/browse/SVLS-8825?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent b67655d commit 27d495f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

.gitlab/templates/pipeline.yaml.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ integration-suite:
508508
- export CDK_DEFAULT_ACCOUNT=$(aws sts get-caller-identity --query Account --output text)
509509
- export CDK_DEFAULT_REGION=us-east-1
510510
- npm run build
511-
- npx cdk deploy "integ-${IDENTIFIER}-${TEST_SUITE}" --require-approval never
511+
- npx cdk deploy "integ-${IDENTIFIER}-${TEST_SUITE}" --require-approval never --import-existing-resources
512512
- echo "Running ${TEST_SUITE} integration tests with identifier ${IDENTIFIER}..."
513513
- export TEST_SUITE=${TEST_SUITE}
514514
- npx jest tests/${TEST_SUITE}.test.ts

0 commit comments

Comments
 (0)