クラウド管理者は、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 インスタンスをプロビジョニングする方法を示しています。
ヘルパーは 1 対多で設定でき、1 つのヘルパーで複数のリソースに対してゾーン配置などの割り当てロジックを提供できます。そのうえで、クラウド プロバイダで定義され、関連付けられたプラグインでサポートされる全プロパティのリストに従ってリソースを細かくカスタマイズします。
この例では、コンピューティング ヘルパー、フレーバー ヘルパー、イメージ ヘルパー、およびネットワーク ヘルパーを使用します。
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 インスタンスをプロビジョニングする方法を示しています。この例では、2 つのプラグイン ベースの インスタンスと 1 つのプラグイン ベースの AWS ボリュームをプロビジョニングします。AWS ボリュームはインスタンスの 1 つに接続され、従来の 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}