作为云管理员,您可以在构建基础架构时利用 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 的 ID。 |
以下部分包含用于置备 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}