VMware Aria Automation
中設定以外掛程式為基礎的 EC2 執行個體

身為雲端管理員,您可以在建置基礎結構時利用 Amazon Web Services (AWS) 外掛程式佈建以外掛程式為基礎的 EC2 執行個體。此外,還可以使用配置協助程式為執行個體提供配置邏輯。
可以使用最新的 AWS 內容輕鬆設定 EC2 執行個體以支援您的基礎結構需求。例如,如果希望在狀態檢查失敗時自動復原執行個體,則可以在佈建期間在範本中使用
auto_recovery_enabled
內容。
若要進一步瞭解
VMware Aria Automation
中的外掛程式和配置,請參閱Automation Assembler 中以外掛程式為基礎的設計和部署

EC2執行個體內容

以外掛程式為基礎的 EC2 執行個體資源需要以下內容。
內容
說明
name
執行個體的名稱。
region
將部署執行個體的區域。
account
您的團隊在其中部署範本的 AWS 雲端帳戶。如需詳細資訊,請參閱在 VMware Aria Automation 中建立 Amazon Web Services 雲端帳戶
image_id
要用於執行個體的 AMI 的識別碼。
以下區段包含用於佈建 EC2 執行個體的範例範本。

佈建簡單的 EC2 執行個體

以下範本顯示了如何佈建 EC2 執行個體並對其所有內容使用靜態設定的值。
formatVersion: 1 inputs: {} resources: Idem_AWS_EC2_INSTANCE_1: type: Idem.AWS.EC2.INSTANCE properties: name: my-instance-1 region: us-east-1 account: AWS image_id: ami-0aa7d40eeae50c9a9 availability_zone: us-east-1a instance_type: t2.small subnet_id: subnet-07d2c529b6336bd0e

使用配置協助程式佈建 EC2 執行個體

以下範本顯示了如何使用多個配置協助程式佈建 EC2 執行個體。
可以透過一對多組態使用協助程式,即一個協助程式為多個資源提供配置邏輯,例如區域放置。之後,可以根據由雲端提供者定義並由關聯外掛程式支援的完整內容清單進一步自訂資源。
在此範例中,將使用計算協助程式、類型模板協助程式、映像協助程式以及網路協助程式。
formatVersion: 1 inputs: instance_name: type: string resources: Allocations_Compute_1: type: Allocations.Compute properties: constraints: - tag: env:dev Allocations_Flavor_1: type: Allocations.Flavor properties: flavor: small Allocations_Image_1: type: Allocations.Image properties: image: ubuntu Allocations_Network_1: type: Allocations.Network properties: networkType: existing constraints: - tag: alternative-net Idem_AWS_EC2_INSTANCE_1: type: Idem.AWS.EC2.INSTANCE properties: name: ${input.instance_name} region: ${resource.Allocations_Compute_1.selectedRegion.id} account: ${resource.Allocations_Compute_1.selectedCloudAccount.name} image_id: ${resource.Allocations_Image_1.selectedImageId} availability_zone: ${resource.Allocations_Compute_1.selectedPlacementCompute.id} instance_type: ${resource.Allocations_Flavor_1.selectedInstanceTypeName} subnet_id: ${resource.Allocations_Network_1.selectedSubnet.id}

佈建具有 AWS 磁碟區的 EC2 執行個體

以下範本顯示了如何佈建具有連結磁碟區的 EC2 執行個體。在此範例中,您將佈建兩個以外掛程式為基礎的執行個體和一個以外掛程式為基礎的 AWS 磁碟區。AWS 磁碟區連接到其中一個執行個體,並使用經典 KMS 金鑰進行加密。
AWS 磁碟區和 KMS 金鑰都透過使用內容繫結參照相同的配置協助程式。使用內容繫結可確保在正確的帳戶和區域中佈建資源。
formatVersion: 1 inputs: instance_name: type: string instance2_name: type: string volume_name: type: string resources: Allocations_Compute_1: type: Allocations.Compute properties: constraints: - tag: env:dev Allocations_Flavor_1: type: Allocations.Flavor properties: flavor: small Allocations_Image_1: type: Allocations.Image properties: image: ubuntu Allocations_Network_1: type: Allocations.Network properties: networkType: existing constraints: - tag: alternative-net Idem_AWS_EC2_INSTANCE_1: type: Idem.AWS.EC2.INSTANCE properties: name: ${input.instance_name} region: ${resource.Allocations_Compute_1.selectedRegion.id} account: ${resource.Allocations_Compute_1.selectedCloudAccount.name} image_id: ${resource.Allocations_Image_1.selectedImageId} availability_zone: ${resource.Allocations_Compute_1.selectedPlacementCompute.id} instance_type: ${resource.Allocations_Flavor_1.selectedInstanceTypeName} subnet_id: ${resource.Allocations_Network_1.selectedSubnet.id} Idem_AWS_EC2_INSTANCE_2: type: Idem.AWS.EC2.INSTANCE properties: name: ${input.instance2_name} region: ${resource.Allocations_Compute_1.selectedRegion.id} account: ${resource.Allocations_Compute_1.selectedCloudAccount.name} image_id: ${resource.Allocations_Image_1.selectedImageId} availability_zone: ${resource.Allocations_Compute_1.selectedPlacementCompute.id} instance_type: ${resource.Allocations_Flavor_1.selectedInstanceTypeName} subnet_id: ${resource.Allocations_Network_1.selectedSubnet.id} block_device_mappings: - volume_id: ${resource.Idem_AWS_EC2_VOLUME_1.resource_id} device_name: /dev/sdb Idem_AWS_EC2_VOLUME_1: type: Idem.AWS.EC2.VOLUME properties: name: ${input.volume_name} region: ${resource.Allocations_Compute_1.selectedRegion.id} account: ${resource.Allocations_Compute_1.selectedCloudAccount.name} availability_zone: ${resource.Allocations_Compute_1.selectedPlacementCompute.id} size: 10 volume_type: io2 iops: 100 encrypted: true kms_key_id: ${resource.Cloud_Service_AWS_KMS_Key_1.key_id} Cloud_Service_AWS_KMS_Key_1: type: Cloud.Service.AWS.KMS.Key properties: region: ${resource.Allocations_Compute_1.selectedRegion.id} account: ${resource.Allocations_Compute_1.selectedCloudAccount.name}