gpt4 book ai didi

aws-cloudformation - AWS CDK 管道错误 - 未找到匹配的堆栈 "xxxxx"

转载 作者:行者123 更新时间:2023-12-05 02:43:54 26 4
gpt4 key购买 nike

我部署的最后一个 CDK Pipeline 遇到了困难。
我已按照此处的步骤操作:https://docs.aws.amazon.com/cdk/latest/guide/cdk_pipeline.html整体的经历是相当痛苦的。首先,我必须手动更新 S3 存储桶策略,以让管道从存储桶中读取/写入它,否则我会收到拒绝访问 403 错误。
该部分似乎已解决,但现在,在“UpdatePipeline”阶段,我遇到了以下错误消息: Error: No stack found matching 'PTPipelineStack'. Use "list" to print manifest ,显然,堆栈存在于 CloudFormation 中,如果我运行 cdk list从 CLI 命令我确实看到了 PTPipelineStack。我已经破坏了管道并重新部署了几次“以防万一”,但并没有真正帮助。有什么建议可以帮助解决这个问题吗?

bin/file.ts:

#!/usr/bin/env node
import * as cdk from '@aws-cdk/core'
import 'source-map-support/register'
import { MyPipelineStack } from '../lib/build-pipeline'

const app = new cdk.App()
const pipelineStack = new MyPipelineStack(app, 'PTPipelineStack', {
env: {
account: 'xxxxxxxxxxxx',
region: 'eu-west-1',
},
})


app.synth()

lib/build-pipeline.ts:

import * as codepipeline from '@aws-cdk/aws-codepipeline'
import * as codepipeline_actions from '@aws-cdk/aws-codepipeline-actions'
import { Construct, Stack, StackProps, Stage, StageProps } from '@aws-cdk/core'
import { CdkPipeline, SimpleSynthAction } from '@aws-cdk/pipelines'
import { PasstimeStack } from './passtime-stack'

export class MyApplication extends Stage {
constructor(scope: Construct, id: string, props?: StageProps) {
super(scope, id, props)
new PasstimeStack(this, 'Cognito')
}
}

export class MyPipelineStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props)

const sourceArtifact = new codepipeline.Artifact()
const cloudAssemblyArtifact = new codepipeline.Artifact()

const pipeline = new CdkPipeline(this, 'Pipeline', {
pipelineName: 'PassTimeAppPipeline',
cloudAssemblyArtifact,

sourceAction: new codepipeline_actions.BitBucketSourceAction({
actionName: 'Github',
connectionArn:
'arn:aws:codestar-connections:eu-west-1:xxxxxxxxxxxxxxx',
owner: 'owner',
repo: 'repo',
branch: 'dev',
output: sourceArtifact,
}),

synthAction: SimpleSynthAction.standardNpmSynth({
sourceArtifact,
cloudAssemblyArtifact,

installCommand: 'npm ci',
environment: {
privileged: true,
},
}),
})

pipeline.addApplicationStage(
new MyApplication(this, 'Dev', {
env: {
account: 'xxxxxxxx',
region: 'eu-west-1',
},
})
)
}
}

取决于我的 package.json:

"devDependencies": {
"@aws-cdk/assert": "^1.94.1",
"@types/jest": "^26.0.21",
"@types/node": "14.14.35",
"aws-cdk": "^1.94.1",
"jest": "^26.4.2",
"ts-jest": "^26.5.4",
"ts-node": "^9.0.0",
"typescript": "4.2.3"
},
"dependencies": {
"@aws-cdk/aws-appsync": "^1.94.1",
"@aws-cdk/aws-cloudfront": "^1.94.1",
"@aws-cdk/aws-cloudfront-origins": "^1.94.1",
"@aws-cdk/aws-codebuild": "^1.94.1",
"@aws-cdk/aws-codepipeline": "^1.94.1",
"@aws-cdk/aws-codepipeline-actions": "^1.94.1",
"@aws-cdk/aws-cognito": "^1.94.1",
"@aws-cdk/aws-dynamodb": "^1.94.1",
"@aws-cdk/aws-iam": "^1.94.1",
"@aws-cdk/aws-kms": "^1.94.1",
"@aws-cdk/aws-lambda": "^1.94.1",
"@aws-cdk/aws-lambda-nodejs": "^1.94.1",
"@aws-cdk/aws-pinpoint": "^1.94.1",
"@aws-cdk/aws-s3": "^1.94.1",
"@aws-cdk/aws-s3-deployment": "^1.94.1",
"@aws-cdk/core": "^1.94.1",
"@aws-cdk/custom-resources": "^1.94.1",
"@aws-cdk/pipelines": "^1.94.1",
"@aws-sdk/s3-request-presigner": "^3.9.0",
"source-map-support": "^0.5.16"
}

代码构建日志:

[Container] 2021/03/19 17:43:59 Entering phase INSTALL
--
16 | [Container] 2021/03/19 17:43:59 Running command npm install -g aws-cdk
17 | /usr/local/bin/cdk -> /usr/local/lib/node_modules/aws-cdk/bin/cdk
18 | + <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f8998f8bd59b9c93b8c9d6c1ccd6c9" rel="noreferrer noopener nofollow">[email protected]</a>
19 | added 193 packages from 186 contributors in 6.404s
20 |
21 | [Container] 2021/03/19 17:44:09 Phase complete: INSTALL State: SUCCEEDED
22 | [Container] 2021/03/19 17:44:09 Phase context status code: Message:
23 | [Container] 2021/03/19 17:44:09 Entering phase PRE_BUILD
24 | [Container] 2021/03/19 17:44:10 Phase complete: PRE_BUILD State: SUCCEEDED
25 | [Container] 2021/03/19 17:44:10 Phase context status code: Message:
26 | [Container] 2021/03/19 17:44:10 Entering phase BUILD
27 | [Container] 2021/03/19 17:44:10 Running command cdk -a . deploy PTPipelineStack --require-approval=never --verbose
28 | CDK toolkit version: 1.94.1 (build 60d8f91)
29 | Command line arguments: {
30 | _: [ 'deploy' ],
31 | a: '.',
32 | app: '.',
33 | 'require-approval': 'never',
34 | requireApproval: 'never',
35 | verbose: 1,
36 | v: 1,
37 | lookups: true,
38 | 'ignore-errors': false,
39 | ignoreErrors: false,
40 | json: false,
41 | j: false,
42 | debug: false,
43 | ec2creds: undefined,
44 | i: undefined,
45 | 'version-reporting': undefined,
46 | versionReporting: undefined,
47 | 'path-metadata': true,
48 | pathMetadata: true,
49 | 'asset-metadata': true,
50 | assetMetadata: true,
51 | 'role-arn': undefined,
52 | r: undefined,
53 | roleArn: undefined,
54 | staging: true,
55 | 'no-color': false,
56 | noColor: false,
57 | fail: false,
58 | all: false,
59 | 'build-exclude': [],
60 | E: [],
61 | buildExclude: [],
62 | ci: false,
63 | execute: true,
64 | force: false,
65 | f: false,
66 | parameters: [ {} ],
67 | 'previous-parameters': true,
68 | previousParameters: true,
69 | '$0': '/usr/local/bin/cdk',
70 | STACKS: [ 'PTPipelineStack' ],
71 | 'S-t-a-c-k-s': [ 'PTPipelineStack' ]
72 | }
73 | merged settings: {
74 | versionReporting: true,
75 | pathMetadata: true,
76 | output: 'cdk.out',
77 | app: '.',
78 | context: {},
79 | debug: false,
80 | assetMetadata: true,
81 | requireApproval: 'never',
82 | toolkitBucket: {},
83 | staging: true,
84 | bundlingStacks: [ '*' ],
85 | lookups: true
86 | }
87 | Toolkit stack: CDKToolkit
88 | Setting "CDK_DEFAULT_REGION" environment variable to eu-west-1
89 | Resolving default credentials
90 | Looking up default account ID from STS
91 | Default account ID: xxxxxx
92 | Setting "CDK_DEFAULT_ACCOUNT" environment variable to xxxxxxxxx
93 | context: {
94 | 'aws:cdk:enable-path-metadata': true,
95 | 'aws:cdk:enable-asset-metadata': true,
96 | 'aws:cdk:version-reporting': true,
97 | 'aws:cdk:bundling-stacks': [ '*' ]
98 | }
99 | --app points to a cloud assembly, so we bypass synth
100 | No stack found matching 'PTPipelineStack'. Use "list" to print manifest
101 | Error: No stack found matching 'PTPipelineStack'. Use "list" to print manifest
102 | at CloudAssembly.selectStacks (/usr/local/lib/node_modules/aws-cdk/lib/api/cxapp/cloud-assembly.ts:115:15)
103 | at CdkToolkit.selectStacksForDeploy (/usr/local/lib/node_modules/aws-cdk/lib/cdk-toolkit.ts:385:35)
104 | at CdkToolkit.deploy (/usr/local/lib/node_modules/aws-cdk/lib/cdk-toolkit.ts:111:20)
105 | at initCommandLine (/usr/local/lib/node_modules/aws-cdk/bin/cdk.ts:208:9)
106 |
107 | [Container] 2021/03/19 17:44:10 Command did not exit successfully cdk -a . deploy PTPipelineStack --require-approval=never --verbose exit status 1
108 | [Container] 2021/03/19 17:44:10 Phase complete: BUILD State: FAILED
109 | [Container] 2021/03/19 17:44:10 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: cdk -a . deploy PTPipelineStack --require-approval=never --verbose. Reason: exit status 1
110 | [Container] 2021/03/19 17:44:10 Entering phase POST_BUILD
111 | [Container] 2021/03/19 17:44:10 Phase complete: POST_BUILD State: SUCCEEDED
112 | [Container] 2021/03/19 17:44:10 Phase context status code: Message:

最佳答案

我遇到了同样的问题,我不确定如何解决它,但可以尝试以下一些方法:

  1. 确保您已将 dev 分支推送到 Github,而不仅仅是在本地正确推送,因为这就是您的管道所指向的。 (这是我的问题)
  2. 我之前使用的是 1.94.1,但后来换成了 1.94.0 - 不确定这是否有帮助
  3. 我将 CDK 版本全部修复,因此删除了 ^,这样它们在某些时候就不会与不同版本发生冲突

关于aws-cloudformation - AWS CDK 管道错误 - 未找到匹配的堆栈 "xxxxx",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66720809/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com