gpt4 book ai didi

aws-cloudformation - Cloudformation API GW Integration响应/响应 header

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

可以在 ResponseParameter 中使用 S3 存储桶的 !Ref。例如:

IntegrationResponses:
- ResponseParameters:
method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
method.response.header.Access-Control-Allow-Methods: "'POST,OPTIONS'"
method.response.header.Access-Control-Allow-Origin: "'https://dynamicbucketname.s3-us-west-2.amazonaws.com'"
method.response.header.Access-Control-Allow-Credentials: "'true'"

S3Bucket:
Type: AWS::S3::Bucket
Properties:
PublicAccessBlockConfiguration:
BlockPublicAcls: true
IgnorePublicAcls: false
BlockPublicPolicy: true
RestrictPublicBuckets: true
WebsiteConfiguration:
IndexDocument: index.html
ErrorDocument: error.html

所以本质上我使用的是资源 AWS::S3::Bucket,它允许模板创建存储桶。因此,该名称将是动态的。我希望能够在 Origin 中 !Ref S3Bucket。这可能吗?我知道它可以是静态的,如“'https://www.example.com'”

最佳答案

一种方法是使用 Sub 如下所示功能:

可以在 ResponseParameter 中使用 S3 存储桶的 !Ref。例如:

IntegrationResponses:
- ResponseParameters:
method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
method.response.header.Access-Control-Allow-Methods: "'POST,OPTIONS'"
method.response.header.Access-Control-Allow-Origin: !Sub "'https://${S3Bucket.DomainName}'"
method.response.header.Access-Control-Allow-Credentials: "'true'"

列出了 DomainName 之外的其他 Bucket 返回值 here :

关于aws-cloudformation - Cloudformation API GW Integration响应/响应 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62094791/

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