typescript - 為什麼這個 CDK 應用在執行 cdk deploy 時會給出「Internal Failure」?
我正在嘗試建立一個 CodePipeline,其中有 1 個階段包含 1 個堆疊:NextStack。在執行 cdk deploy 時,我收到 CREATE_FAILED | AWS::CodePipeline::Pipeline | TodolistPipeline/Pipeline Internal Failure,但沒有其他日誌。這個錯誤可能是什麼原因造成的?
bin.ts:
import * as cdk from '@aws-cdk/core';
import { PipelineStack } from './pipeline-stack';
const app = new cdk.App();
new PipelineStack(app, 'TodolistPipeline', {
env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: 'us-east-1' },
});
pipeline-stack.ts:
import { Construct, Stack, StackProps } from '@aws-cdk/core';
import {
CodePipeline,
CodePipelineSource,
ShellStep,
} from '@aws-cdk/pipelines';
import { NextJsStage } from './front-end-stage';
export class PipelineStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const pipeline = new CodePipeline(this, 'MainDeploymentPipeline', {
pipelineName: 'TodolistDeploymentPipeline',
synth: new ShellStep('Synth', {
input: CodePipelineSource.gitHub('AndyW22/todolist', 'main'),
commands: [
'n 16',
'yarn install --frozen-lockfile',
'cd cdk_stack && yarn install --frozen-lockfile && cd ../',
'ts-node cdk_stack/compileNext.ts ',
'npx cdk synth',
],
}),
});
pipeline.addStage(new NextJsStage(this, 'Front-end'));
}
}
前端階段:
import { Construct, StackProps, Stage } from '@aws-cdk/core';
import { NextStack } from './next-stack';
export class NextJsStage extends Stage {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
new NextStack(this, 'FrontEndStack', {
env: {
region: 'us-east-1',
},
analyticsReporting: true,
description: 'Front end NextJS stack for todolist',
});
}
}
下一個堆疊 :
import { Runtime } from '@aws-cdk/aws-lambda';
import * as cdk from '@aws-cdk/core';
import { Duration } from '@aws-cdk/core';
import { NextJSLambdaEdge } from '@sls-next/cdk-construct';
export class NextStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props: cdk.StackProps) {
super(scope, id, props);
new NextJSLambdaEdge(this, 'NextJsApp', {
serverlessBuildOutDir: './build',
runtime: Runtime.NODEJS_12_X,
memory: 1024,
timeout: Duration.seconds(30),
withLogging: true,
name: {
apiLambda: `${id}Api`,
defaultLambda: `Fn${id}`,
imageLambda: `${id}Image`,
},
});
}
}
答案#1
問題最後是出在 AWS Secrets Manager 的密鑰在錯誤的區域,將它添加到正確的區域後問題就解決了。