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

Amazon cloudformation AWS CDK管道错误-未找到匹配的堆栈;xxxxx";,amazon-cloudformation,aws-cdk,aws-codepipeline,aws-codebuild,Amazon Cloudformation,Aws Cdk,Aws Codepipeline,Aws Codebuild,我在部署最后一条CDK管道时遇到了困难我已经按照这里的步骤进行了操作:总体体验相当痛苦。 首先,我必须手动更新S3 bucket策略,让管道从bucket读/写它,否则我会收到拒绝访问403错误。 这一部分似乎已解决,但现在,在“UpdatePieline”阶段,我收到了失败的错误消息:error:找不到与“PTPipelineStack”匹配的堆栈。使用“list”打印清单,当堆栈明显存在于CloudFormation中时,如果我从CLI运行cdk list命令,我确实会看到PTPipelin

我在部署最后一条CDK管道时遇到了困难
我已经按照这里的步骤进行了操作:总体体验相当痛苦。 首先,我必须手动更新S3 bucket策略,让管道从bucket读/写它,否则我会收到拒绝访问403错误。
这一部分似乎已解决,但现在,在“UpdatePieline”阶段,我收到了失败的错误消息:
error:找不到与“PTPipelineStack”匹配的堆栈。使用“list”打印清单
,当堆栈明显存在于CloudFormation中时,如果我从CLI运行
cdk list
命令,我确实会看到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()
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',
        },
      })
    )
  }
}
"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 | + aws-cdk@1.94.1
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:
lib/build pipeline.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()
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',
        },
      })
    )
  }
}
"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 | + aws-cdk@1.94.1
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:
mypackage上的deps.json:

#!/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()
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',
        },
      })
    )
  }
}
"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 | + aws-cdk@1.94.1
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:
代码生成日志:

#!/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()
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',
        },
      })
    )
  }
}
"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 | + aws-cdk@1.94.1
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:

我遇到了同样的问题,我不确定我到底是如何解决的,但这里有一些东西可以尝试:

  • 确保将
    dev
    分支推送到Github,而不仅仅是正确地推送到本地,因为这正是管道所指向的。(这是我的问题)
  • 我使用的是1.94.1,但换成了1.94.0-不确定这是否有用
  • 我使我的CDK版本都是固定的,所以我删除了
    ^
    ,这样它们就不会在某一点上与不同的版本冲突

  • 我昨天终于有了突破
    我上面概述的问题是管道中较早开始的一个问题的结果,事实上,该问题缺乏访问工件的权限。出现在源阶段的原始错误消息:

    上传到S3失败,出现以下错误:访问被拒绝(服务:Amazon S3;状态代码:403;错误代码:AccessDenied;请求ID:xxxx;S3扩展请求ID:xxxx;代理:null)(服务:null;状态代码:0;错误代码:null;请求ID:null;S3扩展请求ID:null;代理:null)(服务:null;状态代码:0;错误代码:null;请求ID:null;S3扩展请求ID:null;代理:null)

    我通过在工件bucket上创建bucket策略解除了管道的阻塞,但如前所述,这实际上只会将问题进一步推到后面。但关注原始问题时,我实际上意识到CDK没有向其创建的角色之一授予足够的权限

    到目前为止,为了在组织中使用Github回购,需要使用依赖CodeStar的“”集成。(v1=访问令牌=私有回购)

    目前,使用CDK设置此功能的唯一方法是使用上面我的代码中所示的
    BitBucketSourceAction

    有趣的是,在部署新管道堆栈时,CDK会创建专用IAM角色并授予以下权限:

    {
    “版本”:“2012-10-17”,
    “声明”:[
    {
    “操作”:“codestar连接:UseConnection”,
    “资源”:“arn:aws:codestar连接:eu-west-1:xxxxx:connection/xxxx”,xx
    “效果”:“允许”
    },
    {
    “行动”:[
    “s3:GetObject*”,
    “s3:GetBucket*”,
    “s3:列表*”,
    “s3:DeleteObject*”,
    “s3:PutObject”,
    “s3:中止*”
    ],
    “资源”:[
    “arn:aws:s3:::bucket”,
    “arn:aws:s3:::bucket/*”
    ],
    “效果”:“允许”
    },
    {
    “行动”:[
    “kms:解密”,
    “kms:DescribeKey”,
    “kms:加密”,
    “kms:ReEncrypt*”,
    “kms:GeneratedTakey*”
    ],
    “资源”:“arn:aws:kms:eu-west-1:xxxxxxx:key/xxxxx”,
    “效果”:“允许”
    }
    ]
    }
    
    开始看起来还可以,但结果证明管道不足以访问bucket并完成各个阶段。我怀疑它缺少
    PutBucketPolicy
    权限。我目前已通过将特定操作替换为
    s3::
    ,对其进行了修复,但应该进行微调


    最后,我使用的是最新和最棒的
    1.94.1
    ,这不是一个deps问题,而是一个CDK问题。我将向aws CDK帮派提出一个问题。你好@Bryan Hunter,谢谢,但我仍然收到了这个问题。我已经通过包锁删除了包,将包降级到1.94.0,重新安装,重新引导,重新部署了包。我仍然是卡住。我还升级了我的节点版本,删除了与我的OU相关的所有标记策略,降级了一些DEP(ts节点等)以与CDK今天发布的版本相匹配。没有。谢谢,将最新更改推送到远程分支修复了
    错误:找不到匹配“stack_name”的堆栈。使用“list”要为我打印清单
    错误。