`cdk deploy --all` 不会部署所有修改后的堆栈

问题描述 投票:0回答:1

当我按照

aws 文档
的建议运行 cdk deploy --all 来部署所有堆栈时,我没有得到所需的行为。

如果我运行

cdk list
,我会得到所有堆栈的列表:

pipeline
pipeline/alpha-stage/externalcommunication (alpha-stage-externalcommunication)
pipeline/alpha-stage/vpc (alpha-stage-vpc)
pipeline/alpha-stage/intercommunication (alpha-stage-intercommunication)
pipeline/alpha-stage/storage (alpha-stage-storage)
pipeline/alpha-stage/service (alpha-stage-service)
pipeline/alpha-stage/observability (alpha-stage-observability)

如果我运行

cdk deploy --all
,则仅创建和部署管道堆栈

[WARNING] aws-cdk-lib.aws_ec2.LaunchTemplateProps#keyName is deprecated.
  - Use `keyPair` instead - https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2-readme.html#using-an-existing-ec2-key-pair
  This API will be removed in the next major release.

✨  Synthesis time: 3.02s

pipeline: deploying... [1/1]
pipeline: creating CloudFormation changeset...

 ✅  pipeline (no changes)

✨  Deployment time: 3.57s

Stack ARN:
arn:aws:cloudformation:eu-west-1:730335428471:stack/pipeline/2667ad20-0315-11ef-906b-0a89280ac13b

✨  Total time: 6.59s

我最初认为也许它没有看到其他堆栈中的任何差异,但是当我手动部署堆栈时,它确实看到了差异并部署了它

cdk deploy pipeline/alpha-stage/externalcommunication --profile cs-dev
[WARNING] aws-cdk-lib.aws_ec2.LaunchTemplateProps#keyName is deprecated.
  - Use `keyPair` instead - https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2-readme.html#using-an-existing-ec2-key-pair
  This API will be removed in the next major release.

✨  Synthesis time: 3.39s

alpha-stage-externalcommunication:  start: Building cba1532de344d46fde76a38d8b956373267f9fbc4a7fe247ce6caa08f05a9fde:730335428471-eu-west-1
alpha-stage-externalcommunication:  success: Built cba1532de344d46fde76a38d8b956373267f9fbc4a7fe247ce6caa08f05a9fde:730335428471-eu-west-1
alpha-stage-externalcommunication:  start: Publishing cba1532de344d46fde76a38d8b956373267f9fbc4a7fe247ce6caa08f05a9fde:730335428471-eu-west-1
alpha-stage-externalcommunication:  success: Published cba1532de344d46fde76a38d8b956373267f9fbc4a7fe247ce6caa08f05a9fde:730335428471-eu-west-1
pipeline/alpha-stage/externalcommunication (alpha-stage-externalcommunication): deploying... [1/1]
alpha-stage-externalcommunication: creating CloudFormation changeset...
[█████▊····················································] (1/10)

2:35:22 PM | UPDATE_IN_PROGRESS   | AWS::CloudFormation::Stack           | alpha-stage-externalcommunication
2:35:25 PM | CREATE_IN_PROGRESS   | AWS::Route53::HostedZone 
...

那么为什么

deploy --all
甚至不尝试部署除
pipeline
之外的任何堆栈?

amazon-web-services aws-cdk
1个回答
0
投票

这是因为您正在使用 CDK Pipelines,它是一个用于通过管道部署 CDK 应用程序的模块。这意味着您的应用程序堆栈(在

pipeline/
下)由管道部署,而不是本地/通过
cdk deploy

要部署堆栈,只需将代码推送到远程 git 存储库并触发管道(默认情况下自动触发)。

如果您想手动执行带外部署,您仍然可以通过指定 glob 模式来实现:

cdk deploy 'pipeline/**'

这是自述文件中的参考:

如果您的应用程序包含管道堆栈,则 cdk list 命令会将堆栈名称显示为路径,显示它们在管道层次结构中的位置(例如 PipelineStack、PipelineStack/Prod、PipelineStack/Prod/MyService 等)。

如果要部署所有堆栈,可以使用标志 --all 或通配符 * 来部署应用程序中的所有堆栈。请注意,如果您有如上所述的堆栈层次结构,--all 和 * 将仅匹配顶层的堆栈。如果要匹配层次结构中的所有堆栈,请使用 。您还可以组合这些模式。例如,如果要部署 Prod 阶段的所有堆栈,可以使用 cdk deploy PipelineStack/Prod/

© www.soinside.com 2019 - 2024. All rights reserved.