मैं CloudFormation में बनाए गए स्टैक से DynamoDb StreamArn को निर्यात करने का प्रयास कर रहा हूं, फिर सर्वरलेस.yml में !ImportValue का उपयोग करके निर्यात का संदर्भ लें।
लेकिन मुझे यह त्रुटि संदेश मिल रहा है:
unknown tag !<!ImportValue> in "/codebuild/output/src/serverless.yml"
क्लाउडफॉर्मेशन और 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
3 जवाब
${cf:stackName.outputKey}
का उपयोग करके हल किया गया
मैं इससे भी जूझता रहा, और मेरे लिए क्या चाल थी:
functions:
foo:
handler: foo.main
events:
- stream:
type: dynamodb
arn:
!ImportValue my-client-table-stream-arn
batchSize: 1
ध्यान दें, कि आंतरिक कार्य ImportValue
एक नई लाइन पर है और इंडेंट किया गया है, अन्यथा cloudformation-template-update-stack.json
उत्पन्न होने पर संपूर्ण event
को अनदेखा कर दिया जाता है।
ऐसा प्रतीत होता है कि आप CloudFormation YAML के लिए !ImportValue
आशुलिपि का उपयोग कर रहे हैं। मेरी समझ यह है कि जब CloudFormation YAML को पार्स करता है, और !ImportValue
वास्तव में उपनाम Fn::ImportValue
। सर्वर रहित फ़ंक्शन दस्तावेज़ीकरण के अनुसार, ऐसा प्रतीत होता है कि उन्हें आयात के Fn::ImportValue
रूप का समर्थन करना चाहिए।
- stream:
type: dynamodb
arn: {"Fn::ImportValue": "my-client-table-stream-arn"}
batchSize: 1
आशा है कि यह आपकी समस्या को हल करने में मदद करता है।
संबंधित सवाल
नए सवाल
amazon-cloudformation
CloudFormation के बारे में प्रश्नों के लिए, Amazon Web Services (AWS) का एक हिस्सा जो संबंधित AWS संसाधनों के संग्रह को प्रबंधित करने का एक तरीका प्रदान करता है।