全部產品
Search
文件中心

Resource Orchestration Service:ALIYUN::ECS::SNatEntry

更新時間:Apr 10, 2025

ALIYUN::ECS::SNatEntry類型用於配置NAT Gateway中的源地址轉換表。

文法

{
  "Type": "ALIYUN::ECS::SNatEntry",
  "Properties": {
    "SNatTableId": String,
    "SNatIp": String,
    "SnatEntryName": String,
    "SourceCIDR": String,
    "SourceVSwitchId": String
  }
}

屬性

屬性名稱類型必須允許更新描述約束
SNatTableId String 源地址轉換表ID。
SNatIp String 用於源地址轉換的公網IP。必須是NAT Gateway中頻寬包的IP。每個NAT Gateway上的公網IP,不能既存在於連接埠轉寄表中,也存在於SNAT表中。
SnatEntryNameStringSNAT條目的名稱。長度為2~128個字元,必須以英文字母或漢字開頭,但不能以http://https://開頭。
SourceCIDRString交換器或ECS執行個體的網段。
  • 交換器粒度:指定交換器的網段(如192.168.1.0/24),當交換器下的ECS執行個體發起互連網訪問請求時,NAT Gateway會為其提供SNAT服務(代理上網服務)。如果SnatIp僅指定了一個公網IP,ECS執行個體使用指定的公網IP訪問互連網;如果SnatIp指定了多個公網IP,ECS執行個體隨機使用SnatIp中的公網IP訪問互連網。
  • ECS粒度:指定ECS執行個體的地址(如192.168.1.1/32),當ECS執行個體發起互連網訪問請求時,NAT Gateway會為其提供SNAT服務(代理上網服務)。如果SnatIp僅指定了一個公網IP,ECS執行個體使用指定的公網IP訪問互連網;如果SnatIp指定了多個公網IP,ECS執行個體隨機使用SnatIp中的公網IP訪問互連網。
不能同時指定SourceCIDR和SourceVSwtichId,必須指定其中之一。
SourceVSwitchId String 可通過NAT Gateway的SNAT功能訪問互連網的ECS執行個體所在的vSwitch ID。 不能同時指定SourceCIDR和SourceVSwtichId,必須指定其中之一。

傳回值

Fn::GetAtt

SNatEntryId:源地址轉換表中的表項ID。

樣本

  • YAML格式

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      SourceVSwitchId:
        Type: String
        AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
        Description: Allow which switch can access internet.
      SNatTableId:
        Type: String
        Description: Create SNAT entry in specified SNAT table.
    Resources:
      SNatTableEntry:
        Type: ALIYUN::ECS::SNatEntry
        Properties:
          SourceVSwitchId:
            Ref: SourceVSwitchId
          SnatEntryName: test_entry_name
          SNatTableId:
            Ref: SNatTableId
          SNatIp: 100.100.100.1
    Outputs:
      SNatEntryId:
        Description: The id of created SNAT entry.
        Value:
          Fn::GetAtt:
            - SNatTableEntry
            - SNatEntryId
  • JSON格式

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
        "SourceVSwitchId": {
          "Type": "String",
          "AssociationProperty": "ALIYUN::ECS::VSwitch::VSwitchId",
          "Description": "Allow which switch can access internet."
        },
        "SNatTableId": {
          "Type": "String",
          "Description": "Create SNAT entry in specified SNAT table."
        }
      },
      "Resources": {
        "SNatTableEntry": {
          "Type": "ALIYUN::ECS::SNatEntry",
          "Properties": {
            "SourceVSwitchId": {
              "Ref": "SourceVSwitchId"
            },
            "SnatEntryName": "test_entry_name",
            "SNatTableId": {
              "Ref": "SNatTableId"
            },
            "SNatIp": "100.100.100.1"
          }
        }
      },
      "Outputs": {
        "SNatEntryId": {
          "Description": "The id of created SNAT entry.",
          "Value": {
            "Fn::GetAtt": [
              "SNatTableEntry",
              "SNatEntryId"
            ]
          }
        }
      }
    }