【发布时间】:2021-05-27 18:52:50
【问题描述】:
我正在尝试使用 boto3 在 lambda 中使用 cloudformation 模板创建 efs 文件系统。并且有兴趣使用 describe_stack 从堆栈中将输出作为 Filesystemid 返回。但是我得到空值作为回报。请提出我在哪里犯错。
错误是:
Response
null
代码是:
import boto3
import time
import json
import botocore
datetime = time.strftime("%Y%m%d%H%M%S")
stackname = 'My-EFS'
region = "ap-south-1"
client = boto3.client('cloudformation')
s = boto3.Session(region_name=region)
def lambda_handler(event, context):
response = client.create_stack(
StackName= stackname,
TemplateURL='https://cloudnaeem.s3.amazonaws.com/efs.yaml',
)
waiter = client.get_waiter('stack_create_complete')
res = waiter.wait(
StackName=stackname,
)
stack = client.describe_stacks(StackName=stackname)
FileSystem_id=None
for v in stack["Stacks"][0]["Outputs"]:
if v["OutputKey"] == "FileSystemId":
FileSystem_id = v["OutputValue"]
return FileSystem_id
模板输出为:
Outputs:
EFS:
Description: The created EFS
Value: !Ref EFSFileSystem
【问题讨论】:
-
你的模板输出是什么?
-
模板输出已编辑,请检查
-
@Marcin,请检查
标签: amazon-web-services aws-lambda amazon-cloudformation amazon-efs