AWS CDK:Api Gateway终端节点无法生成

时间:2020-07-31 08:29:59

标签: amazon-web-services

运行cdk bootstrap && cdk synth && cdk deploy后,我没有在终端中获得端点URL。我也没有在Api Gateway Web控制台中看到新的端点。

这是我在部署阶段看到的:

Do you wish to deploy these changes (y/n)? y
StackName: deploying...
[0%] start: Publishing 00c90632b9fd2c6<removed>:current
[100%] success: Published 00c90632b9fd2c<removed>:current
StackName: creating CloudFormation changeset...
[█████████████████████████████████████] (4/4)

 ✅  StackName

Stack ARN:
arn:aws:cloudformation:us-east-2:939<removed>

这是在我的顶层结构中,我是否缺少生成api网关(和/或lambda处理程序)所需的其他内容?

const lambdaHandler = new lambda.Function(this, 'LambdaHandler', {
      code: lambda.Code.fromAsset(path.join(__dirname, "lambda")),
      handler: 'test.func1',
      runtime: lambda.Runtime.NODEJS_12_X
    });

const lpIntegration = new apiGatewayV2.LambdaProxyIntegration({
  handler: lambdaHandler
});

const api = new apiGatewayV2.HttpApi(this, "httpApi", {
  corsPreflight: {
    allowHeaders: ['Authorization'],
    allowMethods: [apiGatewayV2.HttpMethod.GET, apiGatewayV2.HttpMethod.HEAD, apiGatewayV2.HttpMethod.OPTIONS, apiGatewayV2.HttpMethod.POST],
    allowOrigins: ['*'],
  },
});

api.addRoutes({
  path: '/testEndpoint',
  methods: [apiGatewayV2.HttpMethod.ANY],
  integration: lpIntegration
})


// package.json deps
"devDependencies": {
    "@aws-cdk/assert": "1.55.0",
    "jest": "^25.5.0",
    "ts-jest": "^25.3.1",
    "aws-cdk": "1.55.0",
    "ts-node": "^8.1.0",
    "typescript": "~3.7.2"
  },
  "dependencies": {
    "@aws-cdk/aws-apigatewayv2": "^1.55.0",
    "@aws-cdk/aws-lambda": "^1.55.0",
    "@aws-cdk/core": "1.55.0",

更新

我再次跑aws configure,并确认我所在的地区是us-east-2。 Web控制台还会在此区域显示信息(包括API网关)。

我要从下面的Web控制台添加最新的CloudFormation日志。

2020-07-31 03:14:50 UTC+0700    StackName   UPDATE_COMPLETE -
2020-07-31 03:14:49 UTC+0700    StackName   UPDATE_COMPLETE_CLEANUP_IN_PROGRESS -
2020-07-31 03:14:47 UTC+0700    LambdaHandlerStackNamehttpApiANYtestEndpoint98A4C450PermissionE8E46AF9  CREATE_COMPLETE -
2020-07-31 03:14:42 UTC+0700    httpApiANYtestEndpoint2F5D131D  CREATE_COMPLETE -
2020-07-31 03:14:42 UTC+0700    httpApiANYtestEndpoint2F5D131D  CREATE_IN_PROGRESS  Resource creation Initiated
2020-07-31 03:14:41 UTC+0700    httpApiANYtestEndpoint2F5D131D  CREATE_IN_PROGRESS  -
2020-07-31 03:14:38 UTC+0700    httpApiANYtestEndpointANYtestEndpointIntegration533B29D7    CREATE_COMPLETE -
2020-07-31 03:14:38 UTC+0700    httpApiANYtestEndpointANYtestEndpointIntegration533B29D7    CREATE_IN_PROGRESS  Resource creation Initiated
2020-07-31 03:14:37 UTC+0700    LambdaHandlerStackNamehttpApiANYtestEndpoint98A4C450PermissionE8E46AF9  CREATE_IN_PROGRESS  Resource creation Initiated
2020-07-31 03:14:37 UTC+0700    httpApiANYtestEndpointANYtestEndpointIntegration533B29D7    CREATE_IN_PROGRESS  -
2020-07-31 03:14:37 UTC+0700    LambdaHandlerStackNamehttpApiANYtestEndpoint98A4C450PermissionE8E46AF9  CREATE_IN_PROGRESS  -
2020-07-31 03:14:08 UTC+0700    StackName   UPDATE_IN_PROGRESS  User Initiated

0 个答案:

没有答案