Contoh Image Builder menggunakan AWS CLI - AWS Command Line Interface

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

Contoh Image Builder menggunakan AWS CLI

Contoh kode berikut menunjukkan cara melakukan tindakan dan mengimplementasikan skenario umum dengan menggunakan AWS Command Line Interface with Image Builder.

Tindakan adalah kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.

Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.

Tindakan

Contoh kode berikut menunjukkan cara menggunakancreate-component.

AWS CLI

Untuk membuat komponen

create-componentContoh berikut membuat komponen yang menggunakan file JSON dokumen dan mereferensikan dokumen komponen dalam YAML format yang diunggah ke bucket Amazon S3.

aws imagebuilder create-component \ --cli-input-json file://create-component.json

Isi dari create-component.json:

{ "name": "MyExampleComponent", "semanticVersion": "2019.12.02", "description": "An example component that builds, validates and tests an image", "changeDescription": "Initial version.", "platform": "Windows", "uri": "s3://s3-bucket-name/s3-bucket-path/component.yaml" }

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "clientToken": "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "componentBuildVersionArn": "arn:aws:imagebuilder:us-west-2:123456789012:component/examplecomponent/2019.12.02/1" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakancreate-distribution-configuration.

AWS CLI

Untuk membuat konfigurasi distribusi

create-distribution-configurationContoh berikut membuat konfigurasi distribusi menggunakan JSON file.

aws imagebuilder create-distribution-configuration \ --cli-input-json file:/create-distribution-configuration.json

Isi dari create-distribution-configuration.json:

{ "name": "MyExampleDistribution", "description": "Copies AMI to eu-west-1", "distributions": [ { "region": "us-west-2", "amiDistributionConfiguration": { "name": "Name {{imagebuilder:buildDate}}", "description": "An example image name with parameter references", "amiTags": { "KeyName": "{{ssm:parameter_name}}" }, "launchPermission": { "userIds": [ "123456789012" ] } } }, { "region": "eu-west-1", "amiDistributionConfiguration": { "name": "My {{imagebuilder:buildVersion}} image {{imagebuilder:buildDate}}", "amiTags": { "KeyName": "Value" }, "launchPermission": { "userIds": [ "123456789012" ] } } } ] }

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "clientToken": "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "distributionConfigurationArn": "arn:aws:imagebuilder:us-west-2:123456789012:distribution-configuration/myexampledistribution" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakancreate-image-pipeline.

AWS CLI

Untuk membuat pipeline gambar

create-image-pipelineContoh berikut membuat pipeline gambar menggunakan JSON file.

aws imagebuilder create-image-pipeline \ --cli-input-json file://create-image-pipeline.json

Isi dari create-image-pipeline.json:

{ "name": "MyWindows2016Pipeline", "description": "Builds Windows 2016 Images", "imageRecipeArn": "arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/mybasicrecipe/2019.12.03", "infrastructureConfigurationArn": "arn:aws:imagebuilder:us-west-2:123456789012:infrastructure-configuration/myexampleinfrastructure", "distributionConfigurationArn": "arn:aws:imagebuilder:us-west-2:123456789012:distribution-configuration/myexampledistribution", "imageTestsConfiguration": { "imageTestsEnabled": true, "timeoutMinutes": 60 }, "schedule": { "scheduleExpression": "cron(0 0 * * SUN)", "pipelineExecutionStartCondition": "EXPRESSION_MATCH_AND_DEPENDENCY_UPDATES_AVAILABLE" }, "status": "ENABLED" }

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "clientToken": "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "imagePipelineArn": "arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/mywindows2016pipeline" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakancreate-image-recipe.

AWS CLI

Untuk membuat resep

create-image-recipeContoh berikut membuat resep gambar menggunakan JSON file. Komponen dipasang sesuai urutan yang ditentukan.

aws imagebuilder create-image-recipe \ --cli-input-json file://create-image-recipe.json

Isi dari create-image-recipe.json:

{ "name": "MyBasicRecipe", "description": "This example image recipe creates a Windows 2016 image.", "semanticVersion": "2019.12.03", "components": [ { "componentArn": "arn:aws:imagebuilder:us-west-2:123456789012:component/myexamplecomponent/2019.12.02/1" }, { "componentArn": "arn:aws:imagebuilder:us-west-2:123456789012:component/myimportedcomponent/1.0.0/1" } ], "parentImage": "arn:aws:imagebuilder:us-west-2:aws:image/windows-server-2016-english-full-base-x86/xxxx.x.x" }

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "clientToken": "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "imageRecipeArn": "arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/mybasicrecipe/2019.12.03" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakancreate-image.

AWS CLI

Untuk membuat gambar

create-imageContoh berikut membuat gambar.

aws imagebuilder create-image \ --image-recipe-arn arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/mybasicrecipe/2019.12.03 \ --infrastructure-configuration-arn arn:aws:imagebuilder:us-west-2:123456789012:infrastructure-configuration/myexampleinfrastructure

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "clientToken": "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "imageBuildVersionArn": "arn:aws:imagebuilder:us-west-2:123456789012:image/mybasicrecipe/2019.12.03/1" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

  • Untuk API detailnya, lihat CreateImagedi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakancreate-infrastructure-configuration.

AWS CLI

Untuk membuat konfigurasi infrastruktur

create-infrastructure-configurationContoh berikut membuat konfigurasi infrastruktur menggunakan JSON file.

aws imagebuilder create-infrastructure-configuration \ --cli-input-json file://create-infrastructure-configuration.json

Isi dari create-infrastructure-configuration.json:

{ "name": "MyExampleInfrastructure", "description": "An example that will retain instances of failed builds", "instanceTypes": [ "m5.large", "m5.xlarge" ], "instanceProfileName": "EC2InstanceProfileForImageBuilder", "securityGroupIds": [ "sg-a1b2c3d4" ], "subnetId": "subnet-a1b2c3d4", "logging": { "s3Logs": { "s3BucketName": "bucket-name", "s3KeyPrefix": "bucket-path" } }, "keyPair": "key-pair-name", "terminateInstanceOnFailure": false, "snsTopicArn": "arn:aws:sns:us-west-2:123456789012:sns-topic-name" }

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "clientToken": "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "infrastructureConfigurationArn": "arn:aws:imagebuilder:us-west-2:123456789012:infrastructure-configuration/myexampleinfrastructure" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakandelete-component.

AWS CLI

Untuk menghapus komponen

delete-componentContoh berikut menghapus versi build komponen dengan menentukannya. ARN

aws imagebuilder delete-component \ --component-build-version-arn arn:aws:imagebuilder:us-west-2:123456789012:component/myexamplecomponent/2019.12.02/1

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "componentBuildVersionArn": "arn:aws:imagebuilder:us-west-2:123456789012:component/myexamplecomponent/2019.12.02/1" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakandelete-image-pipeline.

AWS CLI

Untuk menghapus pipeline gambar

delete-image-pipelineContoh berikut menghapus pipeline gambar dengan menentukan nya. ARN

aws imagebuilder delete-image-pipeline \ --image-pipeline-arn arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/my-example-pipeline

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "imagePipelineArn": "arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/mywindows2016pipeline" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakandelete-image-recipe.

AWS CLI

Untuk menghapus resep gambar

delete-image-recipeContoh berikut menghapus resep gambar dengan menentukan nya. ARN

aws imagebuilder delete-image-recipe \ --image-recipe-arn arn:aws:imagebuilder:us-east-1:123456789012:image-recipe/mybasicrecipe/2019.12.03

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "imageRecipeArn": "arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/mybasicrecipe/2019.12.03" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakandelete-image.

AWS CLI

Untuk menghapus gambar

delete-imageContoh berikut menghapus versi build image dengan menentukannya. ARN

aws imagebuilder delete-image \ --image-build-version-arn arn:aws:imagebuilder:us-west-2:123456789012:image/my-example-image/2019.12.02/1

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "imageBuildVersionArn": "arn:aws:imagebuilder:us-west-2:123456789012:image/mybasicrecipe/2019.12.03/1" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

  • Untuk API detailnya, lihat DeleteImagedi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakandelete-infrastructure-configuration.

AWS CLI

Untuk menghapus konfigurasi infrastruktur

delete-infrastructure-configurationContoh berikut menghapus pipeline gambar dengan menentukan nya. ARN

aws imagebuilder delete-infrastructure-configuration \ --infrastructure-configuration-arn arn:aws:imagebuilder:us-east-1:123456789012:infrastructure-configuration/myexampleinfrastructure

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "infrastructureConfigurationArn": "arn:aws:imagebuilder:us-west-2:123456789012:infrastructure-configuration/myexampleinfrastructure" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakanget-component-policy.

AWS CLI

Untuk mendapatkan detail kebijakan komponen

get-component-policyContoh berikut mencantumkan rincian kebijakan komponen dengan menentukan nyaARN.

aws imagebuilder get-component-policy \ --component-arn arn:aws:imagebuilder:us-west-2:123456789012:component/my-example-component/2019.12.03/1

Output:

{ "Policy": "{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": [ "123456789012" ] }, "Action": [ "imagebuilder:GetComponent", "imagebuilder:ListComponents" ], "Resource": [ "arn:aws:imagebuilder:us-west-2:123456789012:component/my-example-component/2019.12.03/1" ] } ] }" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline Image Builder Image Menggunakan AWS CLI < https://docs.aws.amazon.com/imagebuilder/ latest/userguide/managing - image-builder-cli .html>`__ di Panduan Pengguna Image BuilderEC2. EC2

Contoh kode berikut menunjukkan cara menggunakanget-component.

AWS CLI

Untuk mendapatkan detail komponen

get-componentContoh berikut mencantumkan rincian komponen dengan menentukan nyaARN.

aws imagebuilder get-component \ --component-build-version-arn arn:aws:imagebuilder:us-west-2:123456789012:component/component-name/1.0.0/1

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "component": { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:component/component-name/1.0.0/1", "name": "component-name", "version": "1.0.0", "type": "TEST", "platform": "Linux", "owner": "123456789012", "data": "name: HelloWorldTestingDocument\ndescription: This is hello world testing document.\nschemaVersion: 1.0\n\nphases:\n - name: test\n steps:\n - name: HelloWorldStep\n action: ExecuteBash\n inputs:\n commands:\n - echo \"Hello World! Test.\"\n", "encrypted": true, "dateCreated": "2020-01-27T20:43:30.306Z", "tags": {} } }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

  • Untuk API detailnya, lihat GetComponentdi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakanget-distribution-configuration.

AWS CLI

Untuk mendapatkan detail konfigurasi distribusi

get-distribution-configurationContoh berikut menampilkan rincian konfigurasi distribusi dengan menentukan nyaARN.

aws imagebuilder get-distribution-configuration \ --distribution-configuration-arn arn:aws:imagebuilder:us-west-2:123456789012:distribution-configuration/myexampledistribution

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "distributionConfiguration": { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:distribution-configuration/myexampledistribution", "name": "MyExampleDistribution", "description": "Copies AMI to eu-west-1 and exports to S3", "distributions": [ { "region": "us-west-2", "amiDistributionConfiguration": { "name": "Name {{imagebuilder:buildDate}}", "description": "An example image name with parameter references", "amiTags": { "KeyName": "{{ssm:parameter_name}}" }, "launchPermission": { "userIds": [ "123456789012" ] } } }, { "region": "eu-west-1", "amiDistributionConfiguration": { "name": "My {{imagebuilder:buildVersion}} image {{imagebuilder:buildDate}}", "amiTags": { "KeyName": "Value" }, "launchPermission": { "userIds": [ "123456789012" ] } } } ], "dateCreated": "2020-02-19T18:40:10.529Z", "tags": {} } }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakanget-image-pipeline.

AWS CLI

Untuk mendapatkan detail pipa gambar

get-image-pipelineContoh berikut mencantumkan rincian pipa gambar dengan menentukan nyaARN.

aws imagebuilder get-image-pipeline \ --image-pipeline-arn arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/mywindows2016pipeline

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "imagePipeline": { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/mywindows2016pipeline", "name": "MyWindows2016Pipeline", "description": "Builds Windows 2016 Images", "platform": "Windows", "imageRecipeArn": "arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/mybasicrecipe/2019.12.03", "infrastructureConfigurationArn": "arn:aws:imagebuilder:us-west-2:123456789012:infrastructure-configuration/myexampleinfrastructure", "distributionConfigurationArn": "arn:aws:imagebuilder:us-west-2:123456789012:distribution-configuration/myexampledistribution", "imageTestsConfiguration": { "imageTestsEnabled": true, "timeoutMinutes": 60 }, "schedule": { "scheduleExpression": "cron(0 0 * * SUN)", "pipelineExecutionStartCondition": "EXPRESSION_MATCH_AND_DEPENDENCY_UPDATES_AVAILABLE" }, "status": "ENABLED", "dateCreated": "2020-02-19T19:04:01.253Z", "dateUpdated": "2020-02-19T19:04:01.253Z", "tags": {} } }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakanget-image-policy.

AWS CLI

Untuk mendapatkan detail kebijakan gambar

get-image-policyContoh berikut mencantumkan rincian kebijakan gambar dengan menentukannyaARN.

aws imagebuilder get-image-policy \ --image-arn arn:aws:imagebuilder:us-west-2:123456789012:image/my-example-image/2019.12.03/1

Output:

{ "Policy": "{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": [ "123456789012" ] }, "Action": [ "imagebuilder:GetImage", "imagebuilder:ListImages" ], "Resource": [ "arn:aws:imagebuilder:us-west-2:123456789012:image/my-example-image/2019.12.03/1" ] } ] }" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

  • Untuk API detailnya, lihat GetImagePolicydi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakanget-image-recipe-policy.

AWS CLI

Untuk mendapatkan detail kebijakan resep gambar

get-image-recipe-policyContoh berikut mencantumkan rincian kebijakan resep gambar dengan menentukan nyaARN.

aws imagebuilder get-image-recipe-policy \ --image-recipe-arn arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/my-example-image-recipe/2019.12.03/1

Output:

{ "Policy": "{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": [ "123456789012" ] }, "Action": [ "imagebuilder:GetImageRecipe", "imagebuilder:ListImageRecipes" ], "Resource": [ "arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/my-example-image-recipe/2019.12.03/1" ] } ] }" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakanget-image.

AWS CLI

Untuk mendapatkan detail gambar

get-imageContoh berikut mencantumkan rincian gambar dengan menentukan nyaARN.

aws imagebuilder get-image \ --image-build-version-arn arn:aws:imagebuilder:us-west-2:123456789012:image/mybasicrecipe/2019.12.03/1

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "image": { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:image/mybasicrecipe/2019.12.03/1", "name": "MyBasicRecipe", "version": "2019.12.03/1", "platform": "Windows", "state": { "status": "BUILDING" }, "imageRecipe": { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/mybasicrecipe/2019.12.03", "name": "MyBasicRecipe", "description": "This example image recipe creates a Windows 2016 image.", "platform": "Windows", "version": "2019.12.03", "components": [ { "componentArn": "arn:aws:imagebuilder:us-west-2:123456789012:component/myexamplecomponent/2019.12.02/1" }, { "componentArn": "arn:aws:imagebuilder:us-west-2:123456789012:component/myimportedcomponent/1.0.0/1" } ], "parentImage": "arn:aws:imagebuilder:us-west-2:aws:image/windows-server-2016-english-full-base-x86/2019.12.17/1", "dateCreated": "2020-02-14T19:46:16.904Z", "tags": {} }, "infrastructureConfiguration": { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:infrastructure-configuration/myexampleinfrastructure", "name": "MyExampleInfrastructure", "description": "An example that will retain instances of failed builds", "instanceTypes": [ "m5.large", "m5.xlarge" ], "instanceProfileName": "EC2InstanceProfileForImageFactory", "securityGroupIds": [ "sg-a1b2c3d4" ], "subnetId": "subnet-a1b2c3d4", "logging": { "s3Logs": { "s3BucketName": "bucket-name", "s3KeyPrefix": "bucket-path" } }, "keyPair": "Sam", "terminateInstanceOnFailure": false, "snsTopicArn": "arn:aws:sns:us-west-2:123456789012:sns-name", "dateCreated": "2020-02-14T21:21:05.098Z", "tags": {} }, "imageTestsConfiguration": { "imageTestsEnabled": true, "timeoutMinutes": 720 }, "dateCreated": "2020-02-14T23:14:13.597Z", "outputResources": { "amis": [] }, "tags": {} } }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

  • Untuk API detailnya, lihat GetImagedi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakanget-infrastructure-configuration.

AWS CLI

Untuk mendapatkan detail konfigurasi infrastruktur

get-infrastructure-configurationContoh berikut mencantumkan rincian konfigurasi infrastruktur dengan menentukan nyaARN.

aws imagebuilder get-infrastructure-configuration \ --infrastructure-configuration-arn arn:aws:imagebuilder:us-west-2:123456789012:infrastructure-configuration/myexampleinfrastructure

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "infrastructureConfiguration": { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:infrastructure-configuration/myexampleinfrastructure", "name": "MyExampleInfrastructure", "description": "An example that will retain instances of failed builds", "instanceTypes": [ "m5.large", "m5.xlarge" ], "instanceProfileName": "EC2InstanceProfileForImageBuilder", "securityGroupIds": [ "sg-a48c95ef" ], "subnetId": "subnet-a48c95ef", "logging": { "s3Logs": { "s3BucketName": "bucket-name", "s3KeyPrefix": "bucket-path" } }, "keyPair": "Name", "terminateInstanceOnFailure": false, "snsTopicArn": "arn:aws:sns:us-west-2:123456789012:sns-name", "dateCreated": "2020-02-19T19:11:51.858Z", "tags": {} } }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakanimport-component.

AWS CLI

Untuk mengimpor komponen

import-componentContoh berikut mengimpor skrip yang sudah ada sebelumnya menggunakan file. JSON

aws imagebuilder import-component \ --cli-input-json file://import-component.json

Isi dari import-component.json:

{ "name": "MyImportedComponent", "semanticVersion": "1.0.0", "description": "An example of how to import a component", "changeDescription": "First commit message.", "format": "SHELL", "platform": "Windows", "type": "BUILD", "uri": "s3://s3-bucket-name/s3-bucket-path/component.yaml" }

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "clientToken": "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "componentBuildVersionArn": "arn:aws:imagebuilder:us-west-2:123456789012:component/myimportedcomponent/1.0.0/1" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakanlist-component-build-versions.

AWS CLI

Untuk membuat daftar versi pembuatan komponen

list-component-build-versionsContoh berikut mencantumkan versi build komponen dengan versi semantik tertentu.

aws imagebuilder list-component-build-versions --component-version-arn arn:aws:imagebuilder:us-west-2:123456789012:component/myexamplecomponent/2019.12.02

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "componentSummaryList": [ { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:component/myexamplecomponent/2019.12.02/1", "name": "MyExampleComponent", "version": "2019.12.02", "platform": "Windows", "type": "BUILD", "owner": "123456789012", "description": "An example component that builds, validates and tests an image", "changeDescription": "Initial version.", "dateCreated": "2020-02-19T18:53:45.940Z", "tags": { "KeyName": "KeyValue" } } ] }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakanlist-components.

AWS CLI

Untuk daftar semua versi semantik komponen

list-componentsContoh berikut mencantumkan semua versi semantik komponen yang dapat Anda akses. Anda dapat secara opsional memfilter apakah akan mencantumkan komponen yang dimiliki oleh Anda, oleh Amazon, atau yang telah dibagikan dengan Anda oleh akun lain.

aws imagebuilder list-components

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "componentVersionList": [ { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:component/component-name/1.0.0", "name": "component-name", "version": "1.0.0", "platform": "Linux", "type": "TEST", "owner": "123456789012", "dateCreated": "2020-01-27T20:43:30.306Z" } ] }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

  • Untuk API detailnya, lihat ListComponentsdi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakanlist-distribution-configurations.

AWS CLI

Untuk daftar distribusi

list-distribution-configurationsContoh berikut mencantumkan semua distribusi Anda.

aws imagebuilder list-distribution-configurations

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "distributionConfigurationSummaryList": [ { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:distribution-configuration/myexampledistribution", "name": "MyExampleDistribution", "description": "Copies AMI to eu-west-1 and exports to S3", "dateCreated": "2020-02-19T18:40:10.529Z", "tags": { "KeyName": "KeyValue" } } ] }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakanlist-image-build-versions.

AWS CLI

Untuk membuat daftar versi pembuatan gambar

list-image-build-versionsContoh berikut mencantumkan semua versi build image dengan versi semantik.

aws imagebuilder list-image-build-versions \ --image-version-arn arn:aws:imagebuilder:us-west-2:123456789012:image/mybasicrecipe/2019.12.03

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "imageSummaryList": [ { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:image/mybasicrecipe/2019.12.03/7", "name": "MyBasicRecipe", "version": "2019.12.03/7", "platform": "Windows", "state": { "status": "FAILED", "reason": "Can't start SSM Automation for arn arn:aws:imagebuilder:us-west-2:123456789012:image/mybasicrecipe/2019.12.03/7 during building. Parameter \"iamInstanceProfileName\" has a null value." }, "owner": "123456789012", "dateCreated": "2020-02-19T18:56:11.511Z", "outputResources": { "amis": [] }, "tags": {} }, { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:image/mybasicrecipe/2019.12.03/6", "name": "MyBasicRecipe", "version": "2019.12.03/6", "platform": "Windows", "state": { "status": "FAILED", "reason": "An internal error has occurred." }, "owner": "123456789012", "dateCreated": "2020-02-18T22:49:08.142Z", "outputResources": { "amis": [ { "region": "us-west-2", "image": "ami-a1b2c3d4567890ab", "name": "MyBasicRecipe 2020-02-18T22-49-38.704Z", "description": "This example image recipe creates a Windows 2016 image." }, { "region": "us-west-2", "image": "ami-a1b2c3d4567890ab", "name": "Name 2020-02-18T22-49-08.131Z", "description": "Copies AMI to eu-west-2 and exports to S3" }, { "region": "eu-west-2", "image": "ami-a1b2c3d4567890ab", "name": "My 6 image 2020-02-18T22-49-08.131Z", "description": "Copies AMI to eu-west-2 and exports to S3" } ] }, "tags": {} }, { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:image/mybasicrecipe/2019.12.03/5", "name": "MyBasicRecipe", "version": "2019.12.03/5", "platform": "Windows", "state": { "status": "AVAILABLE" }, "owner": "123456789012", "dateCreated": "2020-02-18T16:51:48.403Z", "outputResources": { "amis": [ { "region": "us-west-2", "image": "ami-a1b2c3d4567890ab", "name": "MyBasicRecipe 2020-02-18T16-52-18.965Z", "description": "This example image recipe creates a Windows 2016 image." } ] }, "tags": {} }, { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:image/mybasicrecipe/2019.12.03/4", "name": "MyBasicRecipe", "version": "2019.12.03/4", "platform": "Windows", "state": { "status": "AVAILABLE" }, "owner": "123456789012", "dateCreated": "2020-02-18T16:50:01.827Z", "outputResources": { "amis": [ { "region": "us-west-2", "image": "ami-a1b2c3d4567890ab", "name": "MyBasicRecipe 2020-02-18T16-50-32.280Z", "description": "This example image recipe creates a Windows 2016 image." } ] }, "tags": {} }, { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:image/mybasicrecipe/2019.12.03/3", "name": "MyBasicRecipe", "version": "2019.12.03/3", "platform": "Windows", "state": { "status": "AVAILABLE" }, "owner": "123456789012", "dateCreated": "2020-02-14T23:14:13.597Z", "outputResources": { "amis": [ { "region": "us-west-2", "image": "ami-a1b2c3d4567890ab", "name": "MyBasicRecipe 2020-02-14T23-14-44.243Z", "description": "This example image recipe creates a Windows 2016 image." } ] }, "tags": {} }, { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:image/mybasicrecipe/2019.12.03/2", "name": "MyBasicRecipe", "version": "2019.12.03/2", "platform": "Windows", "state": { "status": "FAILED", "reason": "SSM execution 'a1b2c3d4-5678-90ab-cdef-EXAMPLE11111' failed with status = 'Failed' and failure message = 'Step fails when it is verifying the command has completed. Command a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 returns unexpected invocation result: \n{Status=[Failed], ResponseCode=[1], Output=[\n----------ERROR-------\nfailed to run commands: exit status 1], OutputPayload=[{\"Status\":\"Failed\",\"ResponseCode\":1,\"Output\":\"\\n----------ERROR-------\\nfailed to run commands: exit status 1\",\"CommandId\":\"a1b2c3d4-5678-90ab-cdef-EXAMPLE11111\"}], CommandId=[a1b2c3d4-5678-90ab-cdef-EXAMPLE11111]}. Please refer to Automation Service Troubleshooting Guide for more diagnosis details.'" }, "owner": "123456789012", "dateCreated": "2020-02-14T22:57:42.593Z", "outputResources": { "amis": [] }, "tags": {} } ] }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakanlist-image-pipeline-images.

AWS CLI

Untuk mencantumkan gambar pipa pipa gambar

list-image-pipeline-imagesContoh berikut mencantumkan semua gambar yang dibuat oleh pipeline gambar tertentu.

aws imagebuilder list-image-pipeline-images \ --image-pipeline-arn arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/mywindows2016pipeline

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "imagePipelineList": [ { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/mywindows2016pipeline", "name": "MyWindows2016Pipeline", "description": "Builds Windows 2016 Images", "platform": "Windows", "imageRecipeArn": "arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/mybasicrecipe/2019.12.03", "infrastructureConfigurationArn": "arn:aws:imagebuilder:us-west-2:123456789012:infrastructure-configuration/myexampleinfrastructure", "distributionConfigurationArn": "arn:aws:imagebuilder:us-west-2:123456789012:distribution-configuration/myexampledistribution", "imageTestsConfiguration": { "imageTestsEnabled": true, "timeoutMinutes": 60 }, "schedule": { "scheduleExpression": "cron(0 0 * * SUN)", "pipelineExecutionStartCondition": "EXPRESSION_MATCH_AND_DEPENDENCY_UPDATES_AVAILABLE" }, "status": "ENABLED", "dateCreated": "2020-02-19T19:04:01.253Z", "dateUpdated": "2020-02-19T19:04:01.253Z", "tags": { "KeyName": "KeyValue" } }, { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/sam", "name": "PipelineName", "platform": "Linux", "imageRecipeArn": "arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/recipe-name-a1b2c3d45678/1.0.0", "infrastructureConfigurationArn": "arn:aws:imagebuilder:us-west-2:123456789012:infrastructure-configuration/infrastructureconfiguration-name-a1b2c3d45678", "imageTestsConfiguration": { "imageTestsEnabled": true, "timeoutMinutes": 720 }, "status": "ENABLED", "dateCreated": "2019-12-16T18:19:02.068Z", "dateUpdated": "2019-12-16T18:19:02.068Z", "tags": { "KeyName": "KeyValue" } } ] }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakanlist-image-recipes.

AWS CLI

Untuk daftar resep gambar

list-image-recipesContoh berikut mencantumkan semua resep gambar Anda.

aws imagebuilder list-image-recipes

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "imageRecipeSummaryList": [ { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/mybasicrecipe/2019.12.03", "name": "MyBasicRecipe", "platform": "Windows", "owner": "123456789012", "parentImage": "arn:aws:imagebuilder:us-west-2:aws:image/windows-server-2016-english-full-base-x86/2019.x.x", "dateCreated": "2020-02-19T18:54:25.975Z", "tags": { "KeyName": "KeyValue" } }, { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/recipe-name-a1b2c3d45678/1.0.0", "name": "recipe-name-a1b2c3d45678", "platform": "Linux", "owner": "123456789012", "parentImage": "arn:aws:imagebuilder:us-west-2:aws:image/amazon-linux-2-x86/2019.11.21", "dateCreated": "2019-12-16T18:19:00.120Z", "tags": { "KeyName": "KeyValue" } } ] }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakanlist-images.

AWS CLI

Untuk membuat daftar gambar

list-imagesContoh berikut mencantumkan semua versi semantik yang dapat Anda akses.

aws imagebuilder list-images

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "imageVersionList": [ { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:image/mybasicrecipe/2019.12.03", "name": "MyBasicRecipe", "version": "2019.12.03", "platform": "Windows", "owner": "123456789012", "dateCreated": "2020-02-14T21:29:18.810Z" } ] }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

  • Untuk API detailnya, lihat ListImagesdi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakanlist-infrastructure-configurations.

AWS CLI

Untuk membuat daftar konfigurasi infrastruktur

list-infrastructure-configurationsContoh berikut mencantumkan semua konfigurasi infrastruktur Anda.

aws imagebuilder list-infrastructure-configurations

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "infrastructureConfigurationSummaryList": [ { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:infrastructure-configuration/myexampleinfrastructure", "name": "MyExampleInfrastructure", "description": "An example that will retain instances of failed builds", "dateCreated": "2020-02-19T19:11:51.858Z", "tags": {} }, { "arn": "arn:aws:imagebuilder:us-west-2:123456789012:infrastructure-configuration/infrastructureconfiguration-name-a1b2c3d45678", "name": "infrastructureConfiguration-name-a1b2c3d45678", "dateCreated": "2019-12-16T18:19:01.038Z", "tags": { "KeyName": "KeyValue" } } ] }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakanlist-tags-for-resource.

AWS CLI

Untuk membuat daftar tag untuk sumber daya tertentu

list-tags-for-resourceContoh berikut mencantumkan semua tag untuk sumber daya tertentu.

aws imagebuilder list-tags-for-resource \ --resource-arn arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/mywindows2016pipeline

Output:

{ "tags": { "KeyName": "KeyValue" } }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakanput-component-policy.

AWS CLI

Untuk menerapkan kebijakan sumber daya ke komponen

put-component-policyPerintah berikut menerapkan kebijakan sumber daya ke komponen build untuk mengaktifkan berbagi komponen build lintas akun. Kami sarankan Anda menggunakan RAM CLI perintahcreate-resource-share. Jika Anda menggunakan CLI perintah EC2 Image Builderput-component-policy, Anda juga harus menggunakan RAM CLI perintah promote-resource-share-create-from-policy agar sumber daya dapat dilihat oleh semua prinsipal dengan siapa sumber daya dibagikan.

aws imagebuilder put-component-policy \ --component-arn arn:aws:imagebuilder:us-west-2:123456789012:component/examplecomponent/2019.12.02/1 \ --policy '{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": [ "123456789012" ] }, "Action": [ "imagebuilder:GetComponent", "imagebuilder:ListComponents" ], "Resource": [ "arn:aws:imagebuilder:us-west-2:123456789012:component/examplecomponent/2019.12.02/1" ] } ] }'

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "componentArn": "arn:aws:imagebuilder:us-west-2:123456789012:component/examplecomponent/2019.12.02/1" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakanput-image-policy.

AWS CLI

Untuk menerapkan kebijakan sumber daya ke gambar

put-image-policyPerintah berikut menerapkan kebijakan sumber daya ke gambar untuk mengaktifkan berbagi gambar lintas akun. Kami sarankan Anda menggunakan RAM CLI perintah create-resource-share. Jika Anda menggunakan CLI perintah EC2 Image Builder put-image-policy, Anda juga harus menggunakan RAM CLI perintah promote-resource-share-create -from-policy agar sumber daya dapat dilihat oleh semua prinsipal yang dengannya sumber daya dibagikan.

aws imagebuilder put-image-policy \ --image-arn arn:aws:imagebuilder:us-west-2:123456789012:image/example-image/2019.12.02/1 \ --policy '{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": [ "123456789012" ] }, "Action": [ "imagebuilder:GetImage", "imagebuilder:ListImages" ], "Resource": [ "arn:aws:imagebuilder:us-west-2:123456789012:image/example-image/2019.12.02/1" ] } ] }'

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "imageArn": "arn:aws:imagebuilder:us-west-2:123456789012:image/example-image/2019.12.02/1" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

  • Untuk API detailnya, lihat PutImagePolicydi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakanput-image-recipe-policy.

AWS CLI

Untuk menerapkan kebijakan sumber daya ke resep gambar

put-image-recipe-policyPerintah berikut menerapkan kebijakan sumber daya ke resep gambar untuk mengaktifkan berbagi resep gambar lintas akun. Kami menyarankan Anda menggunakan RAM CLI perintahcreate-resource-share. Jika Anda menggunakan CLI perintah EC2 Image Builderput-image-recipe-policy, Anda juga harus menggunakan RAM CLI perintah promote-resource-share-create-from-policy agar sumber daya dapat dilihat oleh semua prinsipal dengan siapa sumber daya dibagikan.

aws imagebuilder put-image-recipe-policy \ --image-recipe-arn arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/example-image-recipe/2019.12.02 \ --policy '{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": [ "123456789012" ] }, "Action": [ "imagebuilder:GetImageRecipe", "imagebuilder:ListImageRecipes" ], "Resource": [ "arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/example-image-recipe/2019.12.02" ] } ] }'

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "imageRecipeArn": "arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/example-image-recipe/2019.12.02/1" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakanstart-image-pipeline-execution.

AWS CLI

Untuk memulai pipeline gambar secara manual

start-image-pipeline-executionContoh berikut secara manual memulai pipeline gambar.

aws imagebuilder start-image-pipeline-execution \ --image-pipeline-arn arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/mywindows2016pipeline

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "clientToken": "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "imageBuildVersionArn": "arn:aws:imagebuilder:us-west-2:123456789012:image/mybasicrecipe/2019.12.03/1" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakantag-resource.

AWS CLI

Untuk menandai sumber daya

tag-resourceContoh berikut menambahkan dan menandai sumber daya ke EC2 Image Builder menggunakan JSON file.

aws imagebuilder tag-resource \ --cli-input-json file://tag-resource.json

Isi dari tag-resource.json:

{ "resourceArn": "arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/mywindows2016pipeline", "tags": { "KeyName: "KeyValue" } }

Perintah ini tidak menghasilkan output.

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

  • Untuk API detailnya, lihat TagResourcedi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakanuntag-resource.

AWS CLI

Untuk menghapus tag dari sumber daya

untag-resourceContoh berikut menghapus tag dari sumber daya menggunakan JSON file.

aws imagebuilder untag-resource \ --cli-input-json file://tag-resource.json

Isi dari untag-resource.json:

{ "resourceArn": "arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/mywindows2016pipeline", "tagKeys": [ "KeyName" ] }

Perintah ini tidak menghasilkan output.

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

  • Untuk API detailnya, lihat UntagResourcedi Referensi AWS CLI Perintah.

Contoh kode berikut menunjukkan cara menggunakanupdate-distribution-configuration.

AWS CLI

Untuk memperbarui konfigurasi distribusi

update-distribution-configurationContoh berikut memperbarui konfigurasi distribusi menggunakan JSON file.

aws imagebuilder update-distribution-configuration \ --cli-input-json file://update-distribution-configuration.json

Isi dari update-distribution-configuration.json:

{ "distributionConfigurationArn": "arn:aws:imagebuilder:us-west-2:123456789012:distribution-configuration/myexampledistribution", "description": "Copies AMI to eu-west-2 and exports to S3", "distributions": [ { "region": "us-west-2", "amiDistributionConfiguration": { "name": "Name {{imagebuilder:buildDate}}", "description": "An example image name with parameter references" } }, { "region": "eu-west-2", "amiDistributionConfiguration": { "name": "My {{imagebuilder:buildVersion}} image {{imagebuilder:buildDate}}" } } ] }

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakanupdate-image-pipeline.

AWS CLI

Untuk memperbarui pipeline gambar

update-image-pipelineContoh berikut memperbarui pipeline gambar menggunakan JSON file.

aws imagebuilder update-image-pipeline \ --cli-input-json file://update-image-pipeline.json

Isi dari update-image-pipeline.json:

{ "imagePipelineArn": "arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/mywindows2016pipeline", "imageRecipeArn": "arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/mybasicrecipe/2019.12.03", "infrastructureConfigurationArn": "arn:aws:imagebuilder:us-west-2:123456789012:infrastructure-configuration/myexampleinfrastructure", "distributionConfigurationArn": "arn:aws:imagebuilder:us-west-2:123456789012:distribution-configuration/myexampledistribution", "imageTestsConfiguration": { "imageTestsEnabled": true, "timeoutMinutes": 120 }, "schedule": { "scheduleExpression": "cron(0 0 * * MON)", "pipelineExecutionStartCondition": "EXPRESSION_MATCH_AND_DEPENDENCY_UPDATES_AVAILABLE" }, "status": "DISABLED" }

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.

Contoh kode berikut menunjukkan cara menggunakanupdate-infrastructure-configuration.

AWS CLI

Untuk memperbarui konfigurasi infrastruktur

update-infrastructure-configurationContoh berikut memperbarui konfigurasi infrastruktur menggunakan JSON file.

aws imagebuilder update-infrastructure-configuration \ --cli-input-json file:/update-infrastructure-configuration.json

Isi dari update-infrastructure-configuration.json:

{ "infrastructureConfigurationArn": "arn:aws:imagebuilder:us-west-2:123456789012:infrastructure-configuration/myexampleinfrastructure", "description": "An example that will terminate instances of failed builds", "instanceTypes": [ "m5.large", "m5.2xlarge" ], "instanceProfileName": "EC2InstanceProfileForImageFactory", "securityGroupIds": [ "sg-a48c95ef" ], "subnetId": "subnet-a48c95ef", "logging": { "s3Logs": { "s3BucketName": "bucket-name", "s3KeyPrefix": "bucket-path" } }, "terminateInstanceOnFailure": true, "snsTopicArn": "arn:aws:sns:us-west-2:123456789012:sns-name" }

Output:

{ "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111" }

Untuk informasi selengkapnya, lihat Menyiapkan dan Mengelola Pipeline EC2 Image Builder Image Menggunakan Panduan Pengguna EC2 Image Builder AWS CLI di Image Builder.