Todos os produtos
Search
Central de documentação

Resource Orchestration Service:ALIYUN::VPC::VpnAttachment

Última atualização: Jun 30, 2026

O recurso ALIYUN::VPC::VpnAttachment cria uma conexão IPsec-VPN associável a um transit router.

Sintaxe

{
  "Type": "ALIYUN::VPC::VpnAttachment",
  "Properties": {
    "LocalSubnet": String,
    "CustomerGatewayId": String,
    "AutoConfigRoute": Boolean,
    "Name": String,
    "EffectImmediately": Boolean,
    "BgpConfig": Map,
    "RemoteSubnet": String,
    "RemoteCaCert": String,
    "IpsecConfig": Map,
    "NetworkType": String,
    "HealthCheckConfig": Map,
    "EnableNatTraversal": Boolean,
    "IkeConfig": Map,
    "EnableDpd": Boolean,
    "EnableTunnelsBgp": Boolean,
    "TunnelOptionsSpecification": List,
    "ResourceGroupId": String,
    "TunnelBandwidth": String
  }
}

Propriedades

Propriedade

Tipo

Obrigatório

Editável

Descrição

Restrição

LocalSubnet

String

Sim

Sim

Blocos CIDR do lado da virtual private cloud (VPC) usados nas negociações da Fase 2.

Separe vários blocos CIDR com vírgulas (,). Exemplo: 192.168.1.0/24,192.168.2.0/24.

A conexão IPsec-VPN oferece suporte aos seguintes modos de roteamento:

  • Se você definir LocalSubnet e RemoteSubnet como 0.0.0.0/0, o modo de roteamento da conexão IPsec-VPN será Modo de Roteamento por Destino.

  • Se você definir LocalSubnet e RemoteSubnet com blocos CIDR diferentes de 0.0.0.0/0, o modo de roteamento da conexão IPsec-VPN será Fluxos de Dados Protegidos.

Exemplo: 10.1.1.0/24,10.1.2.0/24.

CustomerGatewayId

String

Não

Não

ID do customer gateway.

Nenhuma.

AutoConfigRoute

Boolean

Não

Sim

Indica se as rotas são configuradas automaticamente.

Valores válidos:

  • true (padrão)

  • false

Name

String

Não

Sim

Nome da conexão IPsec-VPN.

Nenhuma.

EffectImmediately

Boolean

Não

Sim

Indica se as configurações da conexão IPsec-VPN são aplicadas imediatamente.

Valores válidos:

  • true: As configurações da conexão IPsec-VPN entram em vigor imediatamente. Nesse caso, as negociações IPsec iniciam assim que a configuração da conexão é concluída.

  • false (padrão): As configurações da conexão IPsec-VPN não entram em vigor imediatamente. Nesse cenário, as negociações IPsec começam apenas após o recebimento de tráfego de entrada.

BgpConfig

Map

Não

Sim

Configurações do Border Gateway Protocol (BGP).

Para mais informações, consulte Propriedades de BgpConfig.

Nota

Antes de adicionar configurações BGP, recomendamos familiarizar-se com o mecanismo de funcionamento e os limites do roteamento dinâmico BGP. Para mais detalhes, consulte Configuração de rota (anexo do Transit Router).

Recomendamos usar um número de sistema autônomo (ASN) privado para estabelecer conexões BGP com a Alibaba Cloud. Consulte a documentação relevante para verificar o intervalo de ASNs privados.

Exemplo:

{"EnableBgp":"true","LocalAsn":"45104","TunnelCidr":"169.254.11.0/30","LocalBgpIp":"169.254.11.1"}

RemoteSubnet

String

Sim

Sim

Blocos CIDR do lado do data center usados nas negociações da Fase 2.

Separe vários blocos CIDR com vírgulas (,). Exemplo: 192.168.3.0/24,192.168.4.0/24.

A conexão IPsec-VPN oferece suporte aos seguintes modos de roteamento:

  • Se você definir LocalSubnet e RemoteSubnet como 0.0.0.0/0, o modo de roteamento da conexão IPsec-VPN será Modo de Roteamento por Destino.

  • Se você definir LocalSubnet e RemoteSubnet com blocos CIDR diferentes de 0.0.0.0/0, o modo de roteamento da conexão IPsec-VPN será Fluxos de Dados Protegidos.

Exemplo: 10.1.3.0/24,10.1.4.0/24.

RemoteCaCert

String

Não

Não

Certificado CA do par usado quando um gateway VPN ShangMi (SM) cria a conexão IPsec-VPN.

Exemplo:

-----BEGIN CERTIFICATE----- MIIB7zCCAZW**** -----END CERTIFICATE-----

IpsecConfig

Map

Não

Sim

Configurações das negociações da Fase 2.

Para mais informações, consulte Propriedades de IpsecConfig.

Exemplo:

{"IpsecEncAlg":"aes","IpsecAuthAlg":"sha1","IpsecPfs":"group2","IpsecLifetime":86400}

EnableTunnelsBgp

Boolean

Não

Não

Aplica-se à criação de conexões IPsec-VPN no modo de túnel duplo.

Indica se o BGP está ativado para os túneis.

Nenhuma

TunnelOptionsSpecification

List

Não

Não

Lista de configurações de túnel.

Para mais informações, consulte Propriedades de TunnelOptionsSpecification.

ResourceGroupId

String

Não

Não

ID do grupo de recursos.

Nenhuma

TunnelBandwidth

String

Não

Não

Especificação de largura de banda para um único túnel.

Valores válidos:

  • Standard (valor padrão): Tipo padrão com largura de banda de 1 Gbps.

  • Large: Largura de banda padrão de 3 Gbps.

NetworkType

String

Não

Não

Tipo de rede da conexão IPsec-VPN.

Valores válidos:

  • public (padrão): Internet. A conexão IPsec-VPN funciona como um túnel de comunicação criptografado pela Internet.

  • private: Rede privada. A conexão IPsec-VPN atua como um túnel de comunicação criptografado sobre uma rede privada.

HealthCheckConfig

Map

Não

Sim

Configurações de verificação de integridade.

Para mais informações, consulte Propriedades de HealthCheckConfig.

Exemplo:

{"enable":"true","dip":"192.168.1.1","sip":"10.1.1.1","interval":"3","retry":"3","Policy": "revoke_route"}

EnableNatTraversal

Boolean

Não

Sim

Indica se o NAT traversal está ativado.

Valores válidos:

  • true (padrão): Ativa o recurso de NAT traversal. Com essa funcionalidade habilitada, o iniciador não verifica as portas UDP durante as negociações de Internet Key Exchange (IKE) e descobre automaticamente dispositivos de gateway NAT ao longo do túnel IPsec-VPN.

  • false: Desativa o recurso de NAT traversal.

IkeConfig

Map

Não

Sim

Configurações das negociações da Fase 1.

Para mais informações, consulte Propriedades de IkeConfig.

EnableDpd

Boolean

Não

Sim

Indica se a detecção de par inativo (DPD) está ativada.

Valores válidos:

  • true (padrão): Ativa o recurso DPD. O iniciador da conexão IPsec-VPN envia pacotes DPD para verificar a existência e a disponibilidade do par. Se nenhuma resposta válida for recebida dentro de um período especificado, a conexão falhará. As Associações de Segurança (SAs) ISAKMP e IPsec serão excluídas, juntamente com o túnel IPsec-VPN.

  • false: Desativa o recurso DPD. O iniciador da conexão IPsec-VPN não envia pacotes DPD.

Sintaxe de BgpConfig

"BgpConfig": {
  "EnableBgp": Boolean,
  "LocalAsn": Number,
  "TunnelCidr": String,
  "LocalBgpIp": String
}

Propriedades de BgpConfig

Propriedade

Tipo

Obrigatório

Editável

Descrição

Restrição

EnableBgp

Boolean

Não

Não

Indica se o BGP está ativado.

Valores válidos:

  • true

  • false (padrão)

LocalAsn

Number

Não

Sim

ASN do lado da Alibaba Cloud.

Valores válidos: 1 a 4294967295. Valor padrão: 45104.

TunnelCidr

String

Não

Sim

Bloco CIDR do túnel IPsec-VPN.

O bloco CIDR deve pertencer a 169.254.0.0/16. A máscara de sub-rede do bloco CIDR deve ter 30 bits de comprimento.

LocalBgpIp

String

Não

Sim

Endereço IP BGP do lado da Alibaba Cloud.

O endereço IP deve estar dentro do intervalo do bloco CIDR do túnel IPsec-VPN.

Sintaxe de IpsecConfig

"IpsecConfig": {
  "IpsecPfs": String,
  "IpsecEncAlg": String,
  "IpsecAuthAlg": String,
  "IpsecLifetime": Integer
}

Propriedades de IpsecConfig

Propriedade

Tipo

Obrigatório

Editável

Descrição

Restrição

IpsecPfs

String

Não

Sim

Algoritmo de troca de chaves Diffie-Hellman (DH) para negociações da Fase 2.

Valores válidos:

  • disabled

  • group1

  • group2 (padrão)

  • group5

  • group14

IpsecEncAlg

String

Não

Sim

Algoritmo de criptografia para negociações da Fase 2.

Valores válidos:

  • aes (padrão)

  • aes192

  • aes256

  • des

  • 3des

IpsecAuthAlg

String

Não

Sim

Algoritmo de autenticação para negociações da Fase 2.

Valores válidos:

  • md5 (padrão)

  • sha1

  • sha256

  • sha384

  • sha512

IpsecLifetime

Integer

Não

Sim

Tempo de vida da SA para negociações da Fase 2.

Unidade: segundos. Valores válidos: 0 a 86400. Valor padrão: 86400.

Sintaxe de TunnelOptionsSpecification

"TunnelOptionsSpecification": {
    "TunnelIndex": Integer,
    "TunnelBgpConfig": Map,
    "TunnelIkeConfig": Map,
    "EnableNatTraversal": Boolean,
    "TunnelIpsecConfig": Map,
    "CustomerGatewayId": String,
    "EnableDpd": Boolean
}

Parâmetros de TunnelOptionsSpecification

Parâmetro

Tipo

Obrigatório

Atualização permitida

Descrição

Restrições

TunnelIndex

Integer

Não

Não

Índice do túnel.

Valores válidos:

  • 1: Primeiro túnel.

  • 2: Segundo túnel.

TunnelBgpConfig

Map

Não

Não

Configuração BGP do túnel.

Para mais informações, consulte Propriedades de TunnelBgpConfig.

Nota

Este parâmetro é obrigatório ao ativar o BGP para a conexão IPsec (ou seja, ao definir o parâmetro EnableTunnelsBgp como true).

TunnelIkeConfig

Map

Não

Não

Configuração de negociação da Fase 1.

Para mais informações, consulte Propriedades de TunnelIkeConfig.

EnableNatTraversal

Boolean

Não

Não

Aplica-se à criação de conexões IPsec no modo de túnel único.

Valores válidos:

  • true (padrão): Ativa o NAT traversal. Quando ativado, o processo de negociação IKE omite a verificação de porta UDP e descobre automaticamente quaisquer dispositivos de NAT Gateway ao longo do túnel VPN.

  • false: Desativa o NAT traversal.

TunnelIpsecConfig

Map

Não

Não

Configuração de negociação da Fase 2.

Para mais informações, consulte Propriedades de TunnelIpsecConfig.

CustomerGatewayId

String

Não

Não

ID do Customer Gateway.

Nota

Este parâmetro é necessário apenas ao criar uma conexão IPsec no modo de túnel único.

EnableDpd

Boolean

Não

Não

Aplica-se à criação de conexões IPsec no modo de túnel único.

Indica se o DPD (detecção de par inativo) está ativado.

Valores válidos:

  • true (padrão): Ativa o DPD. O iniciador IPsec envia pacotes DPD para verificar a disponibilidade do par. Se nenhuma resposta válida for recebida dentro de um período especificado, o par será considerado desconectado, e a ISAKMP SA, as SAs IPsec correspondentes e o túnel seguro serão excluídos.

  • false: Desativa o DPD. O iniciador IPsec não envia pacotes de sondagem DPD.

Sintaxe de TunnelIkeConfig

"TunnelIkeConfig": {
  "IkeVersion": String,
  "RemoteId": String,
  "IkeEncAlg": String,
  "IkeLifetime": Integer,
  "IkeMode": String,
  "Psk": String,
  "IkeAuthAlg": String,
  "IkePfs": String,
  "LocalId": String
}

Propriedades de TunnelIKEConfig

Parâmetro

Tipo

Obrigatório

Atualizável

Descrição

Restrições

IKEVersion

String

Não

Não

Versão do protocolo IKE.

Valores válidos: ikev1 e ikev2. Valor padrão: ikev2.

Em comparação ao IKEv1, o IKEv2 simplifica a negociação de SA e oferece melhor suporte para cenários com múltiplos blocos CIDR.

RemoteId

String

Não

Não

Identificador do par remoto.

Para negociação da Fase 1, o valor pode ter até 100 caracteres e não pode conter espaços. O valor padrão é o endereço IP do customer gateway associado ao túnel.

RemoteId suporta o formato FQDN. Se utilizar o formato FQDN, defina o modo de negociação como aggressive.

IKEEncAlg

String

Não

Não

Algoritmo de criptografia para negociação da Fase 1.

Valores válidos: aes, aes192, aes256, des e 3des. Valor padrão: aes.

IKELifetime

Integer

Não

Não

Tempo de vida da associação de segurança (SA) da Fase 1.

Unidade: segundos.

Intervalo de valores: 0 a 86400. Valor padrão: 86400.

IKEMode

String

Não

Não

Modo de negociação IKE.

Valores válidos:

  • main (padrão): Oferece um processo de negociação mais seguro.

  • aggressive: Proporciona negociação mais rápida e maior taxa de sucesso.

Psk

String

Não

Não

Chave pré-compartilhada.

Usada para autenticação entre o túnel e seu par remoto.

Nota

O túnel e seu par remoto devem usar a mesma chave pré-compartilhada. Caso contrário, não será possível estabelecer a conexão.

IKEAuthAlg

String

Não

Não

Algoritmo de autenticação para negociação da Fase 1.

Valores válidos: md5, sha1, sha256, sha384 e sha512. Valor padrão: sha1.

IKEPfs

String

Não

Não

Algoritmo de troca de chaves Diffie-Hellman para negociação da Fase 1.

Valor padrão: group2.
Valores válidos: group1, group2, group5 e group14.

LocalId

String

Não

Não

Identificador da extremidade local do túnel (lado da Alibaba Cloud).

Para negociação da Fase 1, o valor pode ter até 100 caracteres e não pode conter espaços. O valor padrão é o endereço IP do túnel.

LocalId suporta o formato FQDN. Se utilizar o formato FQDN, defina o modo de negociação como aggressive.

Sintaxe de TunnelBgpConfig

"TunnelBgpConfig": {
  "LocalAsn": Integer,
  "LocalBgpIp": String,
  "TunnelCidr": String
}

Propriedades de TunnelBgpConfig

Parâmetro

Tipo

Obrigatório

Atualização permitida

Descrição

Restrições

LocalAsn

Integer

Não

Não

Número do sistema autônomo (ASN) do lado da Alibaba Cloud do túnel.

Valores válidos: 1 a 4294967295. Padrão: 45104.

Nota

Use um número de sistema autônomo privado para estabelecer a conexão BGP. Para o intervalo de ASN privado, consulte a documentação relevante.

LocalBgpIp

String

Não

Não

Endereço BGP do lado da Alibaba Cloud do túnel.

O endereço deve ser um IP dentro do bloco CIDR BGP.

TunnelCidr

String

Não

Não

Bloco CIDR do túnel.

O bloco CIDR deve ter um comprimento de prefixo de 30 e estar dentro do intervalo 169.254.0.0/16, não podendo ser 169.254.0.0/30, 169.254.1.0/30, 169.254.2.0/30, 169.254.3.0/30, 169.254.4.0/30, 169.254.5.0/30, 169.254.6.0/30 ou 169.254.169.252/30.

Nota

Os dois túneis de uma conexão IPsec devem usar blocos CIDR de túnel diferentes.

Sintaxe de TunnelIpsecConfig

"TunnelIpsecConfig": {
  "IpsecAuthAlg": String,
  "IpsecLifetime": Integer,
  "IpsecEncAlg": String,
  "IpsecPfs": String
}

Propriedades de TunnelIpsecConfig

Parâmetro

Tipo

Obrigatório

Atualizável

Descrição

Restrições

IpsecAuthAlg

String

Não

Não

Algoritmo de autenticação para negociação da Fase 2.

Valores válidos: md5, sha1, sha256, sha384 ou sha512. Padrão: sha1.

IpsecLifetime

Integer

Não

Não

Tempo de vida da associação de segurança (SA) para negociação da Fase 2.

Unidade: segundos.

Intervalo: 0 a 86400. Padrão: 86400.

IpsecEncAlg

String

Não

Não

Algoritmo de criptografia para negociação da Fase 2.

Valores válidos: aes, aes192, aes256, des ou 3des. Padrão: aes.

IpsecPfs

String

Não

Não

Algoritmo de troca de chaves Diffie-Hellman para negociação da Fase 2.

Padrão: group2.
Valores válidos: disabled, group1, group2, group5 ou group14.

Sintaxe de HealthCheckConfig

"HealthCheckConfig": {
  "Policy": String,
  "Enable": Boolean,
  "Dip": String,
  "Retry": Integer,
  "Sip": String,
  "Interval": Integer
}

Propriedades de HealthCheckConfig

Propriedade

Tipo

Obrigatório

Editável

Descrição

Restrição

Policy

String

Não

Sim

Indica se as rotas publicadas são retiradas quando a verificação de integridade falha.

Valores válidos:

  • revoke_route (padrão): Retira as rotas publicadas quando a verificação de integridade falha.

  • reserve_route: Não retira as rotas publicadas quando a verificação de integridade falha.

Enable

Boolean

Não

Sim

Indica se as verificações de integridade estão ativadas.

Valores válidos:

  • true

  • false (padrão)

Dip

String

Não

Sim

Endereço IP de destino para verificações de integridade.

Especifique o endereço IP no lado do data center com o qual a VPC pode se comunicar através da conexão IPsec-VPN.

Retry

Integer

Não

Sim

Número máximo de tentativas de verificação de integridade.

Valor padrão: 3.

Sip

String

Não

Sim

Endereço IP de origem para verificações de integridade.

Especifique o endereço IP no lado da VPC com o qual o data center pode se comunicar através da conexão IPsec-VPN.

Interval

Integer

Não

Sim

Intervalo entre tentativas consecutivas de verificação de integridade.

Unidade: segundos. Valor padrão: 3.

Sintaxe de IkeConfig

"IkeConfig": {
  "IkeAuthAlg": String,
  "LocalId": String,
  "IkeEncAlg": String,
  "IkeVersion": String,
  "IkeMode": String,
  "IkeLifetime": Integer,
  "RemoteId": String,
  "Psk": String,
  "IkePfs": String
}

Propriedades de IkeConfig

Propriedade

Tipo

Obrigatório

Editável

Descrição

Restrição

IkeAuthAlg

String

Não

Sim

Algoritmo de autenticação para negociações da Fase 1.

Valores válidos:

  • md5 (padrão)

  • sha1

  • sha256

  • sha384

  • sha512

LocalId

String

Não

Sim

Identificador da conexão IPsec-VPN no lado da Alibaba Cloud.

O identificador pode ter até 100 caracteres. Esta propriedade está vazia por padrão.

IkeEncAlg

String

Não

Sim

Algoritmo de criptografia para negociações da Fase 1.

Valores válidos:

  • aes (padrão)

  • aes192

  • aes256

  • des

  • 3des

IkeVersion

String

Não

Sim

Versão do protocolo IKE.

Valores válidos:

  • ikev1 (padrão)

  • ikev2

IkeMode

String

Não

Sim

Modo de negociação.

Valores válidos:

  • main (padrão)

  • aggressive

IkeLifetime

Integer

Não

Sim

Tempo de vida da SA para negociações da Fase 1.

Unidade: segundos. Valores válidos: 0 a 86400. Valor padrão: 86400.

RemoteId

String

Não

Sim

Identificador da conexão IPsec-VPN no lado do data center.

O identificador pode ter até 100 caracteres. O valor padrão é o endereço IP do customer gateway.

Psk

String

Não

Sim

Chave pré-compartilhada para autenticação de identidade entre o gateway VPN e o data center.

Aplicam-se os seguintes limites:

  • A chave deve ter de 1 a 100 caracteres e pode conter dígitos, letras maiúsculas e minúsculas, além dos seguintes caracteres: ~!`@#$%^&*()_-+={}[]|;:',.<>/?

  • Se você não especificar uma chave pré-compartilhada, o sistema gera aleatoriamente uma string de 16 caracteres como chave.

Nota

A chave pré-compartilhada da conexão IPsec-VPN deve ser idêntica à chave de autenticação do data center. Caso contrário, não será possível estabelecer uma conexão entre o data center e o gateway VPN.

IkePfs

String

Não

Sim

Algoritmo de troca de chaves DH para negociações da Fase 1.

Valores válidos:

  • group1 (padrão)

  • group2

  • group5

  • group14

Valores de retorno

Fn::GetAtt

  • InternetIp: endereço de gateway da conexão IPsec-VPN.

  • VpnAttachmentId: ID da conexão IPsec-VPN.

  • PeerVpnAttachmentConfig: configurações da conexão IPsec-VPN.

Exemplos

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  AutoConfigRoute:
    Description:
      en: "Specifies whether to automatically configure routes. Valid values:\ntrue\
        \ (default) \nfalse"
    Type: Boolean
  BgpConfig:
    AssociationPropertyMetadata:
      Parameters:
        EnableBgp:
          Description:
            en: "Specifies whether to enable the BGP feature for the tunnel. \nValid\
              \ values: true and false. Default value: false."
          Type: Boolean
        LocalAsn:
          Description:
            en: 'the ASN on the Alibaba Cloud side. Valid values: 1 to 4294967295.
              Default value: 45104.'
          MaxValue: 4294967295
          MinValue: 1
          Type: Number
        LocalBgpIp:
          Description:
            en: "the BGP IP address on the Alibaba Cloud side. \nThis IP address must\
              \ fall within the CIDR block of the IPsec tunnel."
          Type: String
        TunnelCidr:
          Description:
            en: the CIDR block of the IPsec tunnel. The CIDR block must fall within
              169.254.0.0/16. The subnet mask of the CIDR block must be 30 bits in
              length.
          Type: String
    Description:
      en: "The Border Gateway Protocol (BGP) configuration.\nThis parameter is required\
        \ when the VPN gateway has dynamic BGP enabled.\nBefore you configure BGP,\
        \ we recommend that you learn about how BGP works and its limits. For more\
        \ information, see VPN Gateway supports BGP dynamic routing.\nWe recommend\
        \ that you use a private ASN to establish a connection with Alibaba Cloud\
        \ over BGP. \nRefer to the relevant documentation for the private ASN range."
    Type: Json
  CustomerGatewayId:
    Description:
      en: The ID of the user gateway.
    Type: String
  EffectImmediately:
    Default: false
    Description:
      en: 'Whether to delete the currently negotiated IPsec tunnel and re-initiate
        the negotiation. Value:

        True: Negotiate immediately after the configuration is complete.

        False (default): Negotiate when traffic enters.'
    Type: Boolean
  EnableDpd:
    Description:
      en: "Specifies whether to enable the dead peer detection (DPD) feature. Valid\
        \ values: \ntrue (default) The initiator of the IPsec-VPN connection sends\
        \ DPD packets to verify the existence and availability of the peer. If no\
        \ response is received from the peer within a specified period of time, the\
        \ connection fails. ISAKMP SAs and IPsec SAs are deleted. The IPsec tunnel\
        \ is also deleted. \nfalse: disables DPD. The IPsec initiator does not send\
        \ DPD packets."
    Type: Boolean
  EnableNatTraversal:
    Description:
      en: "Specifies whether to enable NAT traversal. Valid values: \ntrue (default)\
        \ After NAT traversal is enabled, the initiator does not check the UDP ports\
        \ during IKE negotiations and can automatically discover NAT gateway devices\
        \ along the VPN tunnel. \nfalse"
    Type: Boolean
  HealthCheckConfig:
    AssociationPropertyMetadata:
      Parameters:
        Dip:
          Type: String
        Enable:
          Type: Boolean
        Interval:
          Type: Number
        Policy:
          Description:
            en: Whether to revoke published routes when the health check fails.
          Type: String
        Retry:
          Type: Number
        Sip:
          Type: String
    Description:
      en: Whether to enable the health check configuration.
    Type: Json
  IkeConfig:
    AssociationPropertyMetadata:
      Parameters:
        IkeAuthAlg:
          AllowedValues:
          - md5
          - sha1
          - sha256
          - sha384
          - sha512
          - sm3
          Description:
            en: "The authentication algorithm negotiated in the first phase. \nIf\
              \ the VPN gateway instance type is normal, the value is md5|sha1|sha256|sha384|sha512,\
              \ and the default value is md5.\nIf the VPN gateway instance type is\
              \ national secret type, The value is sm3 (default value)."
          Type: String
        IkeEncAlg:
          AllowedValues:
          - aes
          - aes192
          - aes256
          - des
          - 3des
          - sm4
          Description:
            en: "The authentication algorithm negotiated in the first phase. \nIf\
              \ the VPN gateway instance type is normal, the value is aes|aes192|aes256|des|3des,\
              \ and the default value is aes.\nIf the VPN gateway instance type is\
              \ national secret type, The value is sm4 (default value)."
          Type: String
        IkeLifetime:
          Default: 86400
          Description:
            en: The life cycle of the SA negotiated in the first phase. The value
              ranges from 0 to 86400, in seconds. The default value is 86400.
          MaxValue: 86400
          MinValue: 0
          Type: Number
        IkeMode:
          AllowedValues:
          - main
          - aggressive
          Default: main
          Description:
            en: 'Negotiation mode for IKE V1. Value: main|aggressive, default: main.'
          Type: String
        IkePfs:
          AllowedValues:
          - group1
          - group2
          - group5
          - group14
          - group24
          Default: group2
          Description:
            en: 'Diffie-Hellman key exchange algorithm used in the first phase negotiation.
              Value: group1|group2|group5|group14|group24, default value: group2.'
          Type: String
        IkeVersion:
          AllowedValues:
          - ikev1
          - ikev2
          Default: ikev1
          Description:
            en: 'The version of the IKE protocol. Value: ikev1|ikev2, default: ikev1.'
          Type: String
        LocalId:
          Description:
            en: ID of the VPN gateway. The length is limited to 100 characters. The
              default value is the public IP address of the VPN gateway.
          MaxLength: 100
          Type: String
        Psk:
          Description:
            en: Used for identity authentication between the IPsec VPN gateway and
              the user gateway. It is generated randomly by default, or you can specify
              the key manually. The length is limited to 100 characters.
          MaxLength: 100
          Type: String
        RemoteId:
          Description:
            en: ID of the user gateway. The length is limited to 100 characters. The
              default value is the public IP address of the user gateway.
          MaxLength: 100
          Type: String
    Description:
      en: Configuration information for the first phase of negotiation.
    Type: Json
  IpsecConfig:
    AssociationPropertyMetadata:
      Parameters:
        IpsecAuthAlg:
          AllowedValues:
          - md5
          - sha1
          - sha256
          - sha384
          - sha512
          - sm3
          Description:
            en: "The authentication algorithm negotiated in the first phase. \nIf\
              \ the VPN gateway instance type is normal, the value is md5|sha1|sha256|sha384|sha512,\
              \ and the default value is md5.\nIf the VPN gateway instance type is\
              \ national secret type, The value is sm3 (default value)."
          Type: String
        IpsecEncAlg:
          AllowedValues:
          - aes
          - aes192
          - aes256
          - des
          - 3des
          - sm4
          Description:
            en: "The authentication algorithm negotiated in the second phase. \nIf\
              \ the VPN gateway instance type is normal, the value is aes|aes192|aes256|des|3des,\
              \ and the default value is aes.\nIf the VPN gateway instance type is\
              \ national secret type, The value is sm4 (default value)."
          Type: String
        IpsecLifetime:
          Default: 86400
          Description:
            en: 'IpsecLifetime: The life cycle of the SA negotiated in the second
              phase. The value ranges from 0 to 86400, in seconds. The default value
              is 86400.'
          MaxValue: 86400
          MinValue: 0
          Type: Number
        IpsecPfs:
          AllowedValues:
          - disabled
          - group1
          - group2
          - group5
          - group14
          - group24
          Default: group2
          Description:
            en: 'Forwards all protocol packets. The Diffie-Hellman key exchange algorithm
              used in the first phase negotiation, the value: group1|group2|group5|group14|group24,
              default value: group2.'
          Type: String
    Description:
      en: Configuration information for the second phase negotiation.
    Type: Json
  LocalSubnet:
    Description:
      en: 'A network segment on the VPC side that needs to be interconnected with
        the local IDC for the second phase negotiation.

        Multiple network segments are separated by commas, for example: 192.168.1.0/24,
        192.168.2.0/24.'
    Type: String
  Name:
    Description:
      en: 'The name of the IPsec connection.

        The length is 2-128 characters and must start with a letter or Chinese. It
        can contain numbers, periods (.), underscores (_) and dashes (-), but cannot
        start with http:// or https:// .'
    MaxLength: 128
    MinLength: 2
    Type: String
  NetworkType:
    AllowedValues:
    - public
    - private
    Description:
      en: 'The network type of the IPsec connection. Value: public|private.'
    Type: String
  RemoteCaCert:
    Description:
      en: "The peer CA certificate when a ShangMi (SM) VPN gateway is used to establish\
        \ the IPsec-VPN connection. \nThis parameter is required when an SM VPN gateway\
        \ is used to establish the IPsec-VPN connection. \nYou can ignore this parameter\
        \ when a standard VPN gateway is used to create the IPsec-VPN connection."
    Type: String
  RemoteSubnet:
    Description:
      en: 'The network segment of the local IDC is used for the second phase negotiation.

        Multiple network segments are separated by commas, for example: 192.168.3.0/24,
        192.168.4.0/24.'
    Type: String
Resources:
  VpnAttachment:
    Properties:
      AutoConfigRoute:
        Ref: AutoConfigRoute
      BgpConfig:
        Ref: BgpConfig
      CustomerGatewayId:
        Ref: CustomerGatewayId
      EffectImmediately:
        Ref: EffectImmediately
      EnableDpd:
        Ref: EnableDpd
      EnableNatTraversal:
        Ref: EnableNatTraversal
      HealthCheckConfig:
        Ref: HealthCheckConfig
      IkeConfig:
        Ref: IkeConfig
      IpsecConfig:
        Ref: IpsecConfig
      LocalSubnet:
        Ref: LocalSubnet
      Name:
        Ref: Name
      NetworkType:
        Ref: NetworkType
      RemoteCaCert:
        Ref: RemoteCaCert
      RemoteSubnet:
        Ref: RemoteSubnet
    Type: ALIYUN::VPC::VpnAttachment
Outputs:
  InternetIp:
    Description: The gateway IP address of the IPsec connection.
    Value:
      Fn::GetAtt:
      - VpnAttachment
      - InternetIp
  PeerVpnAttachmentConfig:
    Description: Peer vpc Attachment config.
    Value:
      Fn::GetAtt:
      - VpnAttachment
      - PeerVpnAttachmentConfig
  VpnAttachmentId:
    Description: ID of the IPsec attachment.
    Value:
      Fn::GetAtt:
      - VpnAttachment
      - VpnAttachmentId
                        
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "LocalSubnet": {
      "Type": "String",
      "Description": {
        "en": "A network segment on the VPC side that needs to be interconnected with the local IDC for the second phase negotiation.\nMultiple network segments are separated by commas, for example: 192.168.1.0/24, 192.168.2.0/24."
      }
    },
    "CustomerGatewayId": {
      "Type": "String",
      "Description": {
        "en": "The ID of the user gateway."
      }
    },
    "AutoConfigRoute": {
      "Type": "Boolean",
      "Description": {
        "en": "Specifies whether to automatically configure routes. Valid values:\ntrue (default) \nfalse"
      }
    },
    "Name": {
      "Type": "String",
      "Description": {
        "en": "The name of the IPsec connection.\nThe length is 2-128 characters and must start with a letter or Chinese. It can contain numbers, periods (.), underscores (_) and dashes (-), but cannot start with http:// or https:// ."
      },
      "MinLength": 2,
      "MaxLength": 128
    },
    "EffectImmediately": {
      "Type": "Boolean",
      "Description": {
        "en": "Whether to delete the currently negotiated IPsec tunnel and re-initiate the negotiation. Value:\nTrue: Negotiate immediately after the configuration is complete.\nFalse (default): Negotiate when traffic enters."
      },
      "Default": false
    },
    "BgpConfig": {
      "AssociationPropertyMetadata": {
        "Parameters": {
          "EnableBgp": {
            "Type": "Boolean",
            "Description": {
              "en": "Specifies whether to enable the BGP feature for the tunnel. \nValid values: true and false. Default value: false."
            }
          },
          "LocalAsn": {
            "Type": "Number",
            "Description": {
              "en": "the ASN on the Alibaba Cloud side. Valid values: 1 to 4294967295. Default value: 45104."
            },
            "MinValue": 1,
            "MaxValue": 4294967295
          },
          "TunnelCidr": {
            "Type": "String",
            "Description": {
              "en": "the CIDR block of the IPsec tunnel. The CIDR block must fall within 169.254.0.0/16. The subnet mask of the CIDR block must be 30 bits in length."
            }
          },
          "LocalBgpIp": {
            "Type": "String",
            "Description": {
              "en": "the BGP IP address on the Alibaba Cloud side. \nThis IP address must fall within the CIDR block of the IPsec tunnel."
            }
          }
        }
      },
      "Type": "Json",
      "Description": {
        "en": "The Border Gateway Protocol (BGP) configuration.\nThis parameter is required when the VPN gateway has dynamic BGP enabled.\nBefore you configure BGP, we recommend that you learn about how BGP works and its limits. For more information, see VPN Gateway supports BGP dynamic routing.\nWe recommend that you use a private ASN to establish a connection with Alibaba Cloud over BGP. \nRefer to the relevant documentation for the private ASN range."
      }
    },
    "RemoteSubnet": {
      "Type": "String",
      "Description": {
        "en": "The network segment of the local IDC is used for the second phase negotiation.\nMultiple network segments are separated by commas, for example: 192.168.3.0/24, 192.168.4.0/24."
      }
    },
    "RemoteCaCert": {
      "Type": "String",
      "Description": {
        "en": "The peer CA certificate when a ShangMi (SM) VPN gateway is used to establish the IPsec-VPN connection. \nThis parameter is required when an SM VPN gateway is used to establish the IPsec-VPN connection. \nYou can ignore this parameter when a standard VPN gateway is used to create the IPsec-VPN connection."
      }
    },
    "IpsecConfig": {
      "AssociationPropertyMetadata": {
        "Parameters": {
          "IpsecPfs": {
            "Type": "String",
            "Description": {
              "en": "Forwards all protocol packets. The Diffie-Hellman key exchange algorithm used in the first phase negotiation, the value: group1|group2|group5|group14|group24, default value: group2."
            },
            "AllowedValues": [
              "disabled",
              "group1",
              "group2",
              "group5",
              "group14",
              "group24"
            ],
            "Default": "group2"
          },
          "IpsecEncAlg": {
            "Type": "String",
            "Description": {
              "en": "The authentication algorithm negotiated in the second phase. \nIf the VPN gateway instance type is normal, the value is aes|aes192|aes256|des|3des, and the default value is aes.\nIf the VPN gateway instance type is national secret type, The value is sm4 (default value)."
            },
            "AllowedValues": [
              "aes",
              "aes192",
              "aes256",
              "des",
              "3des",
              "sm4"
            ]
          },
          "IpsecAuthAlg": {
            "Type": "String",
            "Description": {
              "en": "The authentication algorithm negotiated in the first phase. \nIf the VPN gateway instance type is normal, the value is md5|sha1|sha256|sha384|sha512, and the default value is md5.\nIf the VPN gateway instance type is national secret type, The value is sm3 (default value)."
            },
            "AllowedValues": [
              "md5",
              "sha1",
              "sha256",
              "sha384",
              "sha512",
              "sm3"
            ]
          },
          "IpsecLifetime": {
            "Type": "Number",
            "Description": {
              "en": "IpsecLifetime: The life cycle of the SA negotiated in the second phase. The value ranges from 0 to 86400, in seconds. The default value is 86400."
            },
            "MinValue": 0,
            "MaxValue": 86400,
            "Default": 86400
          }
        }
      },
      "Type": "Json",
      "Description": {
        "en": "Configuration information for the second phase negotiation."
      }
    },
    "NetworkType": {
      "Type": "String",
      "Description": {
        "en": "The network type of the IPsec connection. Value: public|private."
      },
      "AllowedValues": [
        "public",
        "private"
      ]
    },
    "HealthCheckConfig": {
      "AssociationPropertyMetadata": {
        "Parameters": {
          "Policy": {
            "Type": "String",
            "Description": {
              "en": "Whether to revoke published routes when the health check fails."
            }
          },
          "Enable": {
            "Type": "Boolean"
          },
          "Dip": {
            "Type": "String"
          },
          "Retry": {
            "Type": "Number"
          },
          "Sip": {
            "Type": "String"
          },
          "Interval": {
            "Type": "Number"
          }
        }
      },
      "Type": "Json",
      "Description": {
        "en": "Whether to enable the health check configuration."
      }
    },
    "EnableNatTraversal": {
      "Type": "Boolean",
      "Description": {
        "en": "Specifies whether to enable NAT traversal. Valid values: \ntrue (default) After NAT traversal is enabled, the initiator does not check the UDP ports during IKE negotiations and can automatically discover NAT gateway devices along the VPN tunnel. \nfalse"
      }
    },
    "IkeConfig": {
      "AssociationPropertyMetadata": {
        "Parameters": {
          "IkeAuthAlg": {
            "Type": "String",
            "Description": {
              "en": "The authentication algorithm negotiated in the first phase. \nIf the VPN gateway instance type is normal, the value is md5|sha1|sha256|sha384|sha512, and the default value is md5.\nIf the VPN gateway instance type is national secret type, The value is sm3 (default value)."
            },
            "AllowedValues": [
              "md5",
              "sha1",
              "sha256",
              "sha384",
              "sha512",
              "sm3"
            ]
          },
          "LocalId": {
            "Type": "String",
            "Description": {
              "en": "ID of the VPN gateway. The length is limited to 100 characters. The default value is the public IP address of the VPN gateway."
            },
            "MaxLength": 100
          },
          "IkeEncAlg": {
            "Type": "String",
            "Description": {
              "en": "The authentication algorithm negotiated in the first phase. \nIf the VPN gateway instance type is normal, the value is aes|aes192|aes256|des|3des, and the default value is aes.\nIf the VPN gateway instance type is national secret type, The value is sm4 (default value)."
            },
            "AllowedValues": [
              "aes",
              "aes192",
              "aes256",
              "des",
              "3des",
              "sm4"
            ]
          },
          "IkeVersion": {
            "Type": "String",
            "Description": {
              "en": "The version of the IKE protocol. Value: ikev1|ikev2, default: ikev1."
            },
            "AllowedValues": [
              "ikev1",
              "ikev2"
            ],
            "Default": "ikev1"
          },
          "IkeMode": {
            "Type": "String",
            "Description": {
              "en": "Negotiation mode for IKE V1. Value: main|aggressive, default: main."
            },
            "AllowedValues": [
              "main",
              "aggressive"
            ],
            "Default": "main"
          },
          "IkeLifetime": {
            "Type": "Number",
            "Description": {
              "en": "The life cycle of the SA negotiated in the first phase. The value ranges from 0 to 86400, in seconds. The default value is 86400."
            },
            "MinValue": 0,
            "MaxValue": 86400,
            "Default": 86400
          },
          "RemoteId": {
            "Type": "String",
            "Description": {
              "en": "ID of the user gateway. The length is limited to 100 characters. The default value is the public IP address of the user gateway."
            },
            "MaxLength": 100
          },
          "Psk": {
            "Type": "String",
            "Description": {
              "en": "Used for identity authentication between the IPsec VPN gateway and the user gateway. It is generated randomly by default, or you can specify the key manually. The length is limited to 100 characters."
            },
            "MaxLength": 100
          },
          "IkePfs": {
            "Type": "String",
            "Description": {
              "en": "Diffie-Hellman key exchange algorithm used in the first phase negotiation. Value: group1|group2|group5|group14|group24, default value: group2."
            },
            "AllowedValues": [
              "group1",
              "group2",
              "group5",
              "group14",
              "group24"
            ],
            "Default": "group2"
          }
        }
      },
      "Type": "Json",
      "Description": {
        "en": "Configuration information for the first phase of negotiation."
      }
    },
    "EnableDpd": {
      "Type": "Boolean",
      "Description": {
        "en": "Specifies whether to enable the dead peer detection (DPD) feature. Valid values: \ntrue (default) The initiator of the IPsec-VPN connection sends DPD packets to verify the existence and availability of the peer. If no response is received from the peer within a specified period of time, the connection fails. ISAKMP SAs and IPsec SAs are deleted. The IPsec tunnel is also deleted. \nfalse: disables DPD. The IPsec initiator does not send DPD packets."
      }
    }
  },
  "Resources": {
    "VpnAttachment": {
      "Type": "ALIYUN::VPC::VpnAttachment",
      "Properties": {
        "LocalSubnet": {
          "Ref": "LocalSubnet"
        },
        "CustomerGatewayId": {
          "Ref": "CustomerGatewayId"
        },
        "AutoConfigRoute": {
          "Ref": "AutoConfigRoute"
        },
        "Name": {
          "Ref": "Name"
        },
        "EffectImmediately": {
          "Ref": "EffectImmediately"
        },
        "BgpConfig": {
          "Ref": "BgpConfig"
        },
        "RemoteSubnet": {
          "Ref": "RemoteSubnet"
        },
        "RemoteCaCert": {
          "Ref": "RemoteCaCert"
        },
        "IpsecConfig": {
          "Ref": "IpsecConfig"
        },
        "NetworkType": {
          "Ref": "NetworkType"
        },
        "HealthCheckConfig": {
          "Ref": "HealthCheckConfig"
        },
        "EnableNatTraversal": {
          "Ref": "EnableNatTraversal"
        },
        "IkeConfig": {
          "Ref": "IkeConfig"
        },
        "EnableDpd": {
          "Ref": "EnableDpd"
        }
      }
    }
  },
  "Outputs": {
    "InternetIp": {
      "Description": "The gateway IP address of the IPsec connection.",
      "Value": {
        "Fn::GetAtt": [
          "VpnAttachment",
          "InternetIp"
        ]
      }
    },
    "VpnAttachmentId": {
      "Description": "ID of the IPsec attachment.",
      "Value": {
        "Fn::GetAtt": [
          "VpnAttachment",
          "VpnAttachmentId"
        ]
      }
    },
    "PeerVpnAttachmentConfig": {
      "Description": "Peer vpc Attachment config.",
      "Value": {
        "Fn::GetAtt": [
          "VpnAttachment",
          "PeerVpnAttachmentConfig"
        ]
      }
    }
  }
}