gpt4 book ai didi

aws-cloudformation - 无服务器框架中的 !ImportValue 不起作用

转载 作者:行者123 更新时间:2023-12-04 23:14:41 26 4
gpt4 key购买 nike

我尝试从 CloudFormation 中创建的堆栈导出 DynamoDb StreamArn,然后使用 serverless.yml 中的 !ImportValue 引用导出。

但我收到此错误消息:

unknown tag !<!ImportValue> in "/codebuild/output/src/serverless.yml"

cloudformation 和 serverless.yml 定义如下。任何帮助表示赞赏。

StackA.yml

AWSTemplateFormatVersion: 2010-09-09
Description: Resources for the registration site

Resources:
ClientTable:
Type: AWS::DynamoDB::Table
DeletionPolicy: Retain
Properties:
TableName: client
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 2
WriteCapacityUnits: 2
StreamSpecification:
StreamViewType: NEW_AND_OLD_IMAGES

Outputs:
ClientTableStreamArn:
Description: The ARN for My ClientTable Stream
Value: !GetAtt ClientTable.StreamArn
Export:
Name: my-client-table-stream-arn

serverless.yml

service: my-service

frameworkVersion: ">=1.1.0 <2.0.0"

provider:
name: aws
runtime: nodejs6.10
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:DescribeStream
- dynamodb:GetRecords
- dynamodb:GetShardIterator
- dynamodb:ListStreams
- dynamodb:GetItem
- dynamodb:PutItem
Resource: arn:aws:dynamodb:*:*:table/client

functions:

foo:
handler: foo.main
events:
- stream:
type: dynamodb
arn: !ImportValue my-client-table-stream-arn
batchSize: 1

最佳答案

使用${cf:stackName.outputKey}解决

关于aws-cloudformation - 无服务器框架中的 !ImportValue 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46003563/

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