如何使用AWS CloudFormation在AWS API Gateway上应用安全策略?

5

我有一个简单的CloudFormation模板,用于为API Gateway创建自定义域名,
该模板能够成功创建自定义域名。

但是我找不到设置自定义域名安全策略TLS 1.2的CloudFormation属性,
该模板会创建具有默认TLS 1.0安全策略的自定义域名。

模板:

AWSTemplateFormatVersion: 2010-09-09
Transform: 'AWS::Serverless-2016-10-31'
Description: Test Custom Domain

Resources:
  test:
    Type: AWS::ApiGateway::DomainName
    Properties: 
      CertificateArn: !Sub 'arn:aws:acm:${AWS::Region}:${AWS::AccountId}:certificate/xxxx-xxx-xxx-xxxx-xxxx'
      DomainName: 'test-api.example.com'
      EndpointConfiguration: 
        Types: 
          - 'EDGE'

参考 -
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainname.html

这个参考链接提供了关于Amazon API Gateway域名资源的详细信息。该资源允许您将自己的域名映射到API Gateway REST API上,从而使您的客户可以使用易于记忆和可定制的网址来访问您的API。此外,AWS CloudFormation提供了一种简便的方式来创建和管理API网关域名资源。
2个回答

5

2020年7月增加了在API网关域上指定安全策略的支持。如何将此参数添加到CloudFormation模板的文档可在AWS Docs中找到。安全策略的有效值为TLS_1_0TLS_1_2。以下是示例:

ApiCustomDomainName:
  Type: 'AWS::ApiGateway::DomainName'
  Condition: ApiGatewayEnabled
  Properties:
    DomainName: "example.com"
    RegionalCertificateArn: !Ref CertificateArn
    securityPolicy: "TLS_1_2"
      EndpointConfiguration:
        Types:
          - REGIONAL

3

不幸的是,该参数目前尚未通过CloudFormation公开。

这里有一张票正在跟踪它的进展 - https://github.com/aws-cloudformation/aws-cloudformation-coverage-roadmap/issues/3

目前,您最好创建一个自定义的CloudFormation资源。

该参数通过API公开,并可以被他们的SDK之一(至少某些)使用 - https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/apigateway.html#APIGateway.Client.create_domain_name

以下是讲解如何创建客户资源的文档 - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html


你能否也看一下这个问题 - https://dev59.com/2bbna4cB1Zd3GeqPVhyq? - Ani
1
我已经在这个帖子上留了一条回复。 - Mat

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接