gpt4 book ai didi

amazon-web-services - 参数名称的 AWS Cloudformation 嵌套堆栈参数类型不存在

转载 作者:行者123 更新时间:2023-12-03 07:18:18 25 4
gpt4 key购买 nike

我正在尝试使用 cloudformation 将父堆栈和嵌套堆栈部署到 AWS。父堆栈看起来像这样

AWSTemplateFormatVersion: '2010-09-09'

Parameters:
VPC:
Description: Choose which VPC the Lambda-functions should be deployed to
Type: AWS::EC2::VPC::Id
Default: vpc-sdjkfnsdjklfn

Subnets:
Description: Choose which subnets Lambda-functions should be deployed to
Type: CommaDelimitedList
Default: "subnet-sdoifno, subnet-sdofjnsdo"

SecurityGroup:
Description: Select the Security Group to use for the Lambda-functions
Type: AWS::EC2::SecurityGroup::Id
Default: sg-sdklfnsdkl

Role:
Description: Role for Lambda functions
Type: String
Default: arn:aws:iam::dlfksd:role/ssdfnsdo

Resources:
RestApi:
Type: AWS::ApiGateway::RestApi
Properties:
Name: "my-api"
Description: "SPP Lambda API"

Stack1:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: 'https://s3.amazonaws.com/bucket/template1.yml'
Parameters:
VPC: !Ref VPC
Subnets: !Join
- ','
- !Ref Subnets
SecurityGroup: !Ref SecurityGroup
Role: !Ref Role
RestApi: !Ref RestApi
ApiResourceParent: !GetAtt "RestApi.RootResourceId"

子堆栈看起来像这样

AWSTemplateFormatVersion: '2010-09-09'

Parameters:
VPC:
Type: AWS::EC2::VPC::Id

Subnets:
Type: CommaDelimitedList

SecurityGroup:
Type: AWS::EC2::SecurityGroup::Id

Role:
Type: String

RestApi:
Type: AWS::ApiGateway::RestApi

ApiResourceParent:
Type: AWS::ApiGateway::Resource

Resources:

Fucntion:
Type: AWS::Lambda::Function
Properties:
Code:
S3Bucket: bucket
S3Key: node_lambdas.zip
Handler: Function.handler
Role: !Ref Role
Runtime: nodejs6.10
Timeout: 300
VpcConfig:
SecurityGroupIds:
- !Ref SecurityGroup
SubnetIds: !Ref Subnets
#Policies: AWSLambdaDynamoDBExecutionRole

Permission:
Type: AWS::Lambda::Permission
Properties:
Action: lambda:InvokeFunction
FunctionName: !GetAtt "Function.Arn"
Principal: "apigateway.amazonaws.com"
SourceArn: !Sub "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${RestApi}/*/*/*"
Resource:
Type: AWS::ApiGateway::Resource
Properties:
RestApiId: !Ref RestApi
ParentId: !Ref ApiResourceParent
PathPart: addadjustments

当我运行 aws cloudformation deploy --template-fileparent-stack.yml --stack-name spp-lambda --region us-east-1 --capability CAPABILITY_IAM 时,我得到以下内容错误

Embedded stack arn:aws:cloudformation:us-east-1:771653148224:stack/spp-lambda-Stack1-97M9BLBUM3A5/4a454a50-c274-11e8-b49c-500c28903236 was not successfully created: Parameter validation failed: parameter type AWS::ApiGateway::RestApi for parameter name RestApi does not exist, parameter type AWS::ApiGateway::Resource for parameter name ApiResourceParent does not exist

它不会提示父模板中显式定义的参数。我希望动态创建和传递它所提示的参数,因为我事先不知道这些值。我做错了什么?

最佳答案

尽管支持某些 AWS 资源类型作为 cloudformation 参数类型,但这并不意味着支持所有资源类型。

您尝试将 API 网关值引用为 AWS 特定的参数类型,但不支持:https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html#aws-specific-parameter-types

我相信使用 String 作为类型就足够了。

关于amazon-web-services - 参数名称的 AWS Cloudformation 嵌套堆栈参数类型不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52541817/

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