使用 AWS CLI 的 AWS AppConfig 範例 - AWS Command Line Interface

使用 AWS CLI 的 AWS AppConfig 範例

下列程式碼範例示範如何使用 AWS Command Line Interface 搭配 AWS AppConfig 來執行動作,並實作常見案例。

Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數,但您可以在其相關情境中查看內容中的動作。

每個範例均包含完整原始程式碼的連結,您可在連結中找到如何在內容中設定和執行程式碼的相關指示。

主題

動作

以下程式碼範例顯示如何使用 create-application

AWS CLI

建立應用程式

下列 create-application 範例會在 AWS AppConfig 中建立應用程式。

aws appconfig create-application \ --name "example-application" \ --description "An application used for creating an example."

輸出:

{ "Description": "An application used for creating an example.", "Id": "339ohji", "Name": "example-application" }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 1:建立 AWS AppConfig 應用程式

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 CreateApplication

以下程式碼範例顯示如何使用 create-configuration-profile

AWS CLI

建立組態設定檔

下列 create-configuration-profile 範例會使用存放在 Parameter Store (Systems Manager 的一項功能) 中的組態,來建立組態設定檔。

aws appconfig create-configuration-profile \ --application-id "339ohji" \ --name "Example-Configuration-Profile" \ --location-uri "ssm-parameter://Example-Parameter" \ --retrieval-role-arn "arn:aws:iam::111122223333:role/Example-App-Config-Role"

輸出:

{ "ApplicationId": "339ohji", "Description": null, "Id": "ur8hx2f", "LocationUri": "ssm-parameter://Example-Parameter", "Name": "Example-Configuration-Profile", "RetrievalRoleArn": "arn:aws:iam::111122223333:role/Example-App-Config-Role", "Type": null, "Validators": null }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 3:建立組態和組態設定檔

以下程式碼範例顯示如何使用 create-environment

AWS CLI

建立環境

下列 create-environment 範例會使用您以 create-application 建立的應用程式,來建立名為 Example-Environment 的 AWS AppConfig 環境。

aws appconfig create-environment \ --application-id "339ohji" \ --name "Example-Environment"

輸出:

{ "ApplicationId": "339ohji", "Description": null, "Id": "54j1r29", "Monitors": null, "Name": "Example-Environment", "State": "ReadyForDeployment" }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 2:建立環境

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 CreateEnvironment

以下程式碼範例顯示如何使用 create-extension-association

AWS CLI

建立延伸模組關聯

下列 create-extension-association 範例會在 AWS AppConfig 中建立新的延伸模組關聯。

aws appconfig create-extension-association \ --region us-west-2 \ --extension-identifier S3-backup-extension \ --resource-identifier "arn:aws:appconfig:us-west-2:123456789012:application/Finance" \ --parameters S3bucket=FinanceConfigurationBackup

輸出:

{ "Id": "a1b2c3d4", "ExtensionArn": "arn:aws:appconfig:us-west-2:123456789012:extension/S3-backup-extension/1", "ResourceArn": "arn:aws:appconfig:us-west-2:123456789012:application/Finance", "Parameters": { "S3bucket": "FinanceConfigurationBackup" }, "ExtensionVersionNumber": 1 }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的使用 AWSAppConfig 延伸模組

以下程式碼範例顯示如何使用 create-extension

AWS CLI

建立延伸模組

下列 create-extension 範例會在 AWS AppConfig 中建立新的延伸模組。

aws appconfig create-extension \ --region us-west-2 \ --name S3-backup-extension \ --actions PRE_CREATE_HOSTED_CONFIGURATION_VERSION=[{Name=S3backup,Uri=arn:aws:lambda:us-west-2:123456789012:function:s3backupfunction,RoleArn=arn:aws:iam::123456789012:role/appconfigextensionrole}] \ --parameters S3bucket={Required=true}

輸出:

{ "Id": "1A2B3C4D", "Name": "S3-backup-extension", "VersionNumber": 1, "Arn": "arn:aws:appconfig:us-west-2:123456789012:extension/1A2B3C4D/1", "Actions": { "PRE_CREATE_HOSTED_CONFIGURATION_VERSION": [ { "Name": "S3backup", "Uri": "arn:aws:lambda:us-west-2:123456789012:function:s3backupfunction", "RoleArn": "arn:aws:iam::123456789012:role/appconfigextensionrole" } ] }, "Parameters": { "S3bucket": { "Required": true } } }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的使用 AWSAppConfig 延伸模組

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 CreateExtension

以下程式碼範例顯示如何使用 create-hosted-configuration-version

AWS CLI

建立託管組態版本

下列 create-hosted-configuration-version 範例會在 AWS AppConfig 託管組態存放區中建立新組態。組態內容必須先轉換為 base64。

aws appconfig create-hosted-configuration-version \ --application-id "339ohji" \ --configuration-profile-id "ur8hx2f" \ --content eyAiTmFtZSI6ICJFeGFtcGxlQXBwbGljYXRpb24iLCAiSWQiOiBFeGFtcGxlSUQsICJSYW5rIjogNyB9 \ --content-type "application/json" \ configuration_version_output_file

configuration_version_output_file 的內容:

{ "Name": "ExampleApplication", "Id": ExampleID, "Rank": 7 }

輸出:

{ "ApplicationId": "339ohji", "ConfigurationProfileId": "ur8hx2f", "VersionNumber": "1", "ContentType": "application/json" }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的關於 AWS AppConfig 託管的組態存放區

以下程式碼範例顯示如何使用 delete-application

AWS CLI

如欲刪除應用程式

下列 delete-application 範例會刪除指定的應用程式。

aws appconfig delete-application \ --application-id 339ohji

此命令不會產生輸出。

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 1:建立 AWS AppConfig 應用程式

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 DeleteApplication

以下程式碼範例顯示如何使用 delete-configuration-profile

AWS CLI

刪除組態設定檔

下列 delete-configuration-profile 範例會刪除指定的組態設定檔。

aws appconfig delete-configuration-profile \ --application-id 339ohji \ --configuration-profile-id ur8hx2f

此命令不會產生輸出。

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 3:建立組態和組態設定檔

以下程式碼範例顯示如何使用 delete-deployment-strategy

AWS CLI

刪除部署策略

下列 delete-deployment-strategy 範例會刪除指定的部署策略。

aws appconfig delete-deployment-strategy \ --deployment-strategy-id 1225qzk

此命令不會產生輸出。

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 4:建立部署策略

以下程式碼範例顯示如何使用 delete-environment

AWS CLI

刪除環境

下列 delete-environment 範例會刪除指定的應用程式環境。

aws appconfig delete-environment \ --application-id 339ohji \ --environment-id 54j1r29

此命令不會產生輸出。

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 2:建立環境

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 DeleteEnvironment

以下程式碼範例顯示如何使用 delete-extension-association

AWS CLI

刪除延伸模組關聯

下列 delete-extension-association 範例會從 AWS AppConfig 刪除延伸模組關聯。

aws appconfig delete-extension-association \ --region us-west-2 \ --extension-association-id a1b2c3d4

此命令不會產生輸出。

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的使用 AWSAppConfig 延伸模組

以下程式碼範例顯示如何使用 delete-extension

AWS CLI

刪除延伸模組

下列 delete-extension 範例會從 AWS AppConfig 刪除延伸模組。

aws appconfig delete-extension \ --region us-west-2 \ --extension-identifier S3-backup-extension

此命令不會產生輸出。

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的使用 AWSAppConfig 延伸模組

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 DeleteExtension

以下程式碼範例顯示如何使用 delete-hosted-configuration-version

AWS CLI

刪除託管組態版本

下列 delete-hosted-configuration-version 範例會刪除託管於 AWS AppConfig 託管組態存放區中的組態版本。

aws appconfig delete-hosted-configuration-version \ --application-id 339ohji \ --configuration-profile-id ur8hx2f \ --version-number 1

輸出:此命令不會產生輸出。

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 3:建立組態和組態設定檔

以下程式碼範例顯示如何使用 get-application

AWS CLI

列出應用程式的詳細資訊

下列 get-application 範例會列出指定應用程式的詳細資訊。

aws appconfig get-application \ --application-id 339ohji

輸出:

{ "Description": "An application used for creating an example.", "Id": "339ohji", "Name": "example-application" }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的 AWS AppConfig 的運作方式

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 GetApplication

以下程式碼範例顯示如何使用 get-configuration-profile

AWS CLI

擷取組態設定檔詳細資訊

下列 get-configuration-profile 範例會傳回指定組態設定檔的詳細資訊。

aws appconfig get-configuration-profile \ --application-id 339ohji \ --configuration-profile-id ur8hx2f

輸出:

{ "ApplicationId": "339ohji", "Id": "ur8hx2f", "Name": "Example-Configuration-Profile", "LocationUri": "ssm-parameter://Example-Parameter", "RetrievalRoleArn": "arn:aws:iam::111122223333:role/Example-App-Config-Role" }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 3:建立組態和組態設定檔

以下程式碼範例顯示如何使用 get-configuration

AWS CLI

擷取組態詳細資訊

下列 get-configuration 範例會傳回範例應用程式的組態詳細資訊。在後續呼叫 get-configuration 時請使用 client-configuration-version 參數,僅在版本有所變更時更新應用程式的組態。只有在版本變更時才更新組態,可以避免因呼叫 get-configuration 而產生超額費用。

aws appconfig get-configuration \ --application "example-application" \ --environment "Example-Environment" \ --configuration "Example-Configuration-Profile" \ --client-id "test-id" \ configuration-output-file

configuration-output-file 的內容:

{ "Name": "ExampleApplication", "Id": ExampleID, "Rank": 7 }

輸出:

{ "ConfigurationVersion": "1", "ContentType": "application/json" }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 6:接收組態

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 GetConfiguration

以下程式碼範例顯示如何使用 get-deployment-strategy

AWS CLI

擷取部署策略的詳細資訊

下列 get-deployment-strategy 範例會列出指定部署策略的詳細資訊。

aws appconfig get-deployment-strategy \ --deployment-strategy-id 1225qzk

輸出:

{ "Id": "1225qzk", "Name": "Example-Deployment", "DeploymentDurationInMinutes": 15, "GrowthType": "LINEAR", "GrowthFactor": 25.0, "FinalBakeTimeInMinutes": 0, "ReplicateTo": "SSM_DOCUMENT" }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 4:建立部署策略

以下程式碼範例顯示如何使用 get-deployment

AWS CLI

擷取部署詳細資訊

下列 get-deployment 範例會列出在指定的環境和部署中部署至應用程式的詳細資訊。

aws appconfig get-deployment \ --application-id 339ohji \ --environment-id 54j1r29 \ --deployment-number 1

輸出:

{ "ApplicationId": "339ohji", "EnvironmentId": "54j1r29", "DeploymentStrategyId": "1225qzk", "ConfigurationProfileId": "ur8hx2f", "DeploymentNumber": 1, "ConfigurationName": "Example-Configuration-Profile", "ConfigurationLocationUri": "ssm-parameter://Example-Parameter", "ConfigurationVersion": "1", "DeploymentDurationInMinutes": 15, "GrowthType": "LINEAR", "GrowthFactor": 25.0, "FinalBakeTimeInMinutes": 0, "State": "COMPLETE", "EventLog": [ { "EventType": "DEPLOYMENT_COMPLETED", "TriggeredBy": "APPCONFIG", "Description": "Deployment completed", "OccurredAt": "2021-09-17T21:59:03.888000+00:00" }, { "EventType": "BAKE_TIME_STARTED", "TriggeredBy": "APPCONFIG", "Description": "Deployment bake time started", "OccurredAt": "2021-09-17T21:58:57.722000+00:00" }, { "EventType": "PERCENTAGE_UPDATED", "TriggeredBy": "APPCONFIG", "Description": "Configuration available to 100.00% of clients", "OccurredAt": "2021-09-17T21:55:56.816000+00:00" }, { "EventType": "PERCENTAGE_UPDATED", "TriggeredBy": "APPCONFIG", "Description": "Configuration available to 75.00% of clients", "OccurredAt": "2021-09-17T21:52:56.567000+00:00" }, { "EventType": "PERCENTAGE_UPDATED", "TriggeredBy": "APPCONFIG", "Description": "Configuration available to 50.00% of clients", "OccurredAt": "2021-09-17T21:49:55.737000+00:00" }, { "EventType": "PERCENTAGE_UPDATED", "TriggeredBy": "APPCONFIG", "Description": "Configuration available to 25.00% of clients", "OccurredAt": "2021-09-17T21:46:55.187000+00:00" }, { "EventType": "DEPLOYMENT_STARTED", "TriggeredBy": "USER", "Description": "Deployment started", "OccurredAt": "2021-09-17T21:43:54.205000+00:00" } ], "PercentageComplete": 100.0, "StartedAt": "2021-09-17T21:43:54.205000+00:00", "CompletedAt": "2021-09-17T21:59:03.888000+00:00" }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 5:部署組態

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 GetDeployment

以下程式碼範例顯示如何使用 get-environment

AWS CLI

擷取環境詳細資訊

下列 get-environment 範例會傳回指定環境的詳細資訊和狀態。

aws appconfig get-environment \ --application-id 339ohji \ --environment-id 54j1r29

輸出:

{ "ApplicationId": "339ohji", "Id": "54j1r29", "Name": "Example-Environment", "State": "ReadyForDeployment" }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 2:建立環境

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 GetEnvironment

以下程式碼範例顯示如何使用 get-extension-association

AWS CLI

取得延伸模組關聯詳細資訊

下列 get-extension-association 範例會顯示延伸模組關聯的相關資訊。

aws appconfig get-extension-association \ --region us-west-2 \ --extension-association-id a1b2c3d4

輸出:

{ "Id": "a1b2c3d4", "ExtensionArn": "arn:aws:appconfig:us-west-2:123456789012:extension/S3-backup-extension/1", "ResourceArn": "arn:aws:appconfig:us-west-2:123456789012:application/Finance", "Parameters": { "S3bucket": "FinanceConfigurationBackup" }, "ExtensionVersionNumber": 1 }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的使用 AWSAppConfig 延伸模組

以下程式碼範例顯示如何使用 get-extension

AWS CLI

取得延伸模組詳細資訊

下列 get-extension 範例會顯示延伸模組的相關資訊。

aws appconfig get-extension \ --region us-west-2 \ --extension-identifier S3-backup-extension

輸出:

{ "Id": "1A2B3C4D", "Name": "S3-backup-extension", "VersionNumber": 1, "Arn": "arn:aws:appconfig:us-west-2:123456789012:extension/S3-backup-extension/1", "Actions": { "PRE_CREATE_HOSTED_CONFIGURATION_VERSION": [ { "Name": "S3backup", "Uri": "arn:aws:lambda:us-west-2:123456789012:function:S3backupfunction", "RoleArn": "arn:aws:iam::123456789012:role/appconfigextensionrole" } ] }, "Parameters": { "S3bucket": { "Required": true } } }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的使用 AWSAppConfig 延伸模組

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 GetExtension

以下程式碼範例顯示如何使用 get-hosted-configuration-version

AWS CLI

擷取託管組態詳細資訊

下列 get-hosted-configuration-version 範例會擷取 AWS AppConfig 託管組態的組態詳細資訊。

aws appconfig get-hosted-configuration-version \ --application-id 339ohji \ --configuration-profile-id ur8hx2f \ --version-number 1 \ hosted-configuration-version-output

hosted-configuration-version-output 的內容:

{ "Name": "ExampleApplication", "Id": ExampleID, "Rank": 7 }

輸出:

{ "ApplicationId": "339ohji", "ConfigurationProfileId": "ur8hx2f", "VersionNumber": "1", "ContentType": "application/json" }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的關於 AWS AppConfig 託管的組態存放區

以下程式碼範例顯示如何使用 list-applications

AWS CLI

列出可用的應用程式

下列 list-applications 範例會列出您的 AWS 帳戶中可用的應用程式。

aws appconfig list-applications

輸出:

{ "Items": [ { "Id": "339ohji", "Name": "test-application", "Description": "An application used for creating an example." }, { "Id": "rwalwu7", "Name": "Test-Application" } ] }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 1:建立 AWS AppConfig 應用程式

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 ListApplications

以下程式碼範例顯示如何使用 list-configuration-profiles

AWS CLI

列出可用的組態設定檔

下列 list-configuration-profiles 範例會列出指定的應用程式可用的組態設定檔。

aws appconfig list-configuration-profiles \ --application-id 339ohji

輸出:

{ "Items": [ { "ApplicationId": "339ohji", "Id": "ur8hx2f", "Name": "Example-Configuration-Profile", "LocationUri": "ssm-parameter://Example-Parameter" } ] }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 3:建立組態和組態設定檔

以下程式碼範例顯示如何使用 list-deployment-strategies

AWS CLI

列出可用的部署策略

下列 list-deployment-strategies 範例會列出您的 AWS 帳戶中可用的部署策略。

aws appconfig list-deployment-strategies

輸出:

{ "Items": [ { "Id": "1225qzk", "Name": "Example-Deployment", "DeploymentDurationInMinutes": 15, "GrowthType": "LINEAR", "GrowthFactor": 25.0, "FinalBakeTimeInMinutes": 0, "ReplicateTo": "SSM_DOCUMENT" }, { "Id": "AppConfig.AllAtOnce", "Name": "AppConfig.AllAtOnce", "Description": "Quick", "DeploymentDurationInMinutes": 0, "GrowthType": "LINEAR", "GrowthFactor": 100.0, "FinalBakeTimeInMinutes": 10, "ReplicateTo": "NONE" }, { "Id": "AppConfig.Linear50PercentEvery30Seconds", "Name": "AppConfig.Linear50PercentEvery30Seconds", "Description": "Test/Demo", "DeploymentDurationInMinutes": 1, "GrowthType": "LINEAR", "GrowthFactor": 50.0, "FinalBakeTimeInMinutes": 1, "ReplicateTo": "NONE" }, { "Id": "AppConfig.Canary10Percent20Minutes", "Name": "AppConfig.Canary10Percent20Minutes", "Description": "AWS Recommended", "DeploymentDurationInMinutes": 20, "GrowthType": "EXPONENTIAL", "GrowthFactor": 10.0, "FinalBakeTimeInMinutes": 10, "ReplicateTo": "NONE" } ] }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 4:建立部署策略

以下程式碼範例顯示如何使用 list-deployments

AWS CLI

列出可用的部署

下列 list-deployments 範例會列出您的 AWS 帳戶中可用於指定應用程式和環境的部署。

aws appconfig list-deployments \ --application-id 339ohji \ --environment-id 54j1r29

輸出:

{ "Items": [ { "DeploymentNumber": 1, "ConfigurationName": "Example-Configuration-Profile", "ConfigurationVersion": "1", "DeploymentDurationInMinutes": 15, "GrowthType": "LINEAR", "GrowthFactor": 25.0, "FinalBakeTimeInMinutes": 0, "State": "COMPLETE", "PercentageComplete": 100.0, "StartedAt": "2021-09-17T21:43:54.205000+00:00", "CompletedAt": "2021-09-17T21:59:03.888000+00:00" } ] }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 5:部署組態

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 ListDeployments

以下程式碼範例顯示如何使用 list-environments

AWS CLI

列出可用的環境

下列 list-environments 範例會列出您的 AWS 帳戶中可用於指定應用程式的環境。

aws appconfig list-environments \ --application-id 339ohji

輸出:

{ "Items": [ { "ApplicationId": "339ohji", "Id": "54j1r29", "Name": "Example-Environment", "State": "ReadyForDeployment" } ] }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 2:建立環境

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 ListEnvironments

以下程式碼範例顯示如何使用 list-extension-associations

AWS CLI

列出您的 AWS 帳戶在 AWS 區域中的所有 AWS AppConfig 延伸模組關聯

下列 list-extension-associations 範例會列出目前的 AWS 帳戶在特定 AWS 區域中的所有 AWS AppConfig 延伸模組關聯。

aws appconfig list-extension-associations \ --region us-west-2

輸出:

{ "Items": [ { "Id": "a1b2c3d4", "ExtensionArn": "arn:aws:appconfig:us-west-2:123456789012:extension/S3-backup-extension/1", "ResourceArn": "arn:aws:appconfig:us-west-2:123456789012:application/Finance" } ] }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的使用 AWSAppConfig 延伸模組

以下程式碼範例顯示如何使用 list-extensions

AWS CLI

列出您的 AWS 帳戶在 AWS 區域中的所有 AWS AppConfig 延伸模組

下列 list-extensions 範例會列出目前的 AWS 帳戶在特定 AWS 區域中的所有 AWS AppConfig 延伸模組。命令會傳回自訂和 AWS 撰寫的延伸模組。

aws appconfig list-extensions \ --region us-west-2

輸出:

{ "Items": [ { "Id": "1A2B3C4D", "Name": "S3-backup-extension", "VersionNumber": 1, "Arn": "arn:aws:appconfig:us-west-2:123456789012:extension/1A2B3C4D/1" }, { "Id": "AWS.AppConfig.FeatureFlags", "Name": "AppConfig Feature Flags Helper", "VersionNumber": 1, "Arn": "arn:aws:appconfig:us-west-2::extension/AWS.AppConfig.FeatureFlags/1", "Description": "Validates AppConfig feature flag data automatically against a JSON schema that includes structure and constraints. Also transforms feature flag data prior to sending to the client. This extension is automatically associated to configuration profiles with type \"AWS.AppConfig.FeatureFlags\"." }, { "Id": "AWS.AppConfig.JiraIntegration", "Name": "AppConfig integration with Atlassian Jira", "VersionNumber": 1, "Arn": "arn:aws:appconfig:us-west-2::extension/AWS.AppConfig.JiraIntegration/1", "Description": "Exports feature flag data from AWS AppConfig into Jira. The lifecycle of each feature flag in AppConfig is tracked in Jira as an individual issue. Customers can see in Jira when flags are updated, turned on or off. Works in conjunction with the AppConfig app in the Atlassian Marketplace and is automatically associated to configuration profiles configured within that app." }, { "Id": "AWS.AppConfig.DeploymentNotificationsToEventBridge", "Name": "AppConfig deployment events to Amazon EventBridge", "VersionNumber": 1, "Arn": "arn:aws:appconfig:us-west-2::extension/AWS.AppConfig.DeploymentNotificationsToEventBridge/1", "Description": "Sends events to Amazon EventBridge when a deployment of configuration data in AppConfig is started, completed, or rolled back. Can be associated to the following resources in AppConfig: Application, Environment, Configuration Profile." }, { "Id": "AWS.AppConfig.DeploymentNotificationsToSqs", "Name": "AppConfig deployment events to Amazon SQS", "VersionNumber": 1, "Arn": "arn:aws:appconfig:us-west-2::extension/AWS.AppConfig.DeploymentNotificationsToSqs/1", "Description": "Sends messages to the configured Amazon SQS queue when a deployment of configuration data in AppConfig is started, completed, or rolled back. Can be associated to the following resources in AppConfig: Application, Environment, Configuration Profile." }, { "Id": "AWS.AppConfig.DeploymentNotificationsToSns", "Name": "AppConfig deployment events to Amazon SNS", "VersionNumber": 1, "Description": "Sends events to the configured Amazon SNS topic when a deployment of configuration data in AppConfig is started, completed, or rolled back. Can be associated to the following resources in AppConfig: Application, Environment, Configuration Profile." } ] }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的使用 AWSAppConfig 延伸模組

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 ListExtensions

以下程式碼範例顯示如何使用 list-hosted-configuration-versions

AWS CLI

列出可用的託管組態版本

下列 list-hosted-configuration-versions 範例會列出為指定的應用程式和組態設定檔託管於 AWS AppConfig 託管組態存放區中的組態版本。

aws appconfig list-hosted-configuration-versions \ --application-id 339ohji \ --configuration-profile-id ur8hx2f

輸出:

{ "Items": [ { "ApplicationId": "339ohji", "ConfigurationProfileId": "ur8hx2f", "VersionNumber": 1, "ContentType": "application/json" } ] }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的關於 AWS AppConfig 託管的組態存放區

以下程式碼範例顯示如何使用 list-tags-for-resource

AWS CLI

列出應用程式的標籤

下列 list-tags-for-resource 範例會列出指定應用程式的標籤。

aws appconfig list-tags-for-resource \ --resource-arn arn:aws:appconfig:us-east-1:682428703967:application/339ohji

輸出:

{ "Tags": { "group1": "1" } }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 1:建立 AWS AppConfig 應用程式

以下程式碼範例顯示如何使用 start-deployment

AWS CLI

啟動組態部署

下列 start-deployment 範例會使用指定的環境、部署策略和組態設定檔開始部署至應用程式。

aws appconfig start-deployment \ --application-id 339ohji \ --environment-id 54j1r29 \ --deployment-strategy-id 1225qzk \ --configuration-profile-id ur8hx2f \ --configuration-version 1

輸出:

{ "ApplicationId": "339ohji", "EnvironmentId": "54j1r29", "DeploymentStrategyId": "1225qzk", "ConfigurationProfileId": "ur8hx2f", "DeploymentNumber": 1, "ConfigurationName": "Example-Configuration-Profile", "ConfigurationLocationUri": "ssm-parameter://Example-Parameter", "ConfigurationVersion": "1", "DeploymentDurationInMinutes": 15, "GrowthType": "LINEAR", "GrowthFactor": 25.0, "FinalBakeTimeInMinutes": 0, "State": "DEPLOYING", "EventLog": [ { "EventType": "DEPLOYMENT_STARTED", "TriggeredBy": "USER", "Description": "Deployment started", "OccurredAt": "2021-09-17T21:43:54.205000+00:00" } ], "PercentageComplete": 0.0, "StartedAt": "2021-09-17T21:43:54.205000+00:00" }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 5:部署組態

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 StartDeployment

以下程式碼範例顯示如何使用 stop-deployment

AWS CLI

停止組態部署

下列 stop-deployment 範例會停止將應用程式組態部署至指定的環境。

aws appconfig stop-deployment \ --application-id 339ohji \ --environment-id 54j1r29 \ --deployment-number 2

輸出:

{ "DeploymentNumber": 0, "DeploymentDurationInMinutes": 0, "GrowthFactor": 0.0, "FinalBakeTimeInMinutes": 0, "PercentageComplete": 0.0 }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 5:部署組態

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 StopDeployment

以下程式碼範例顯示如何使用 tag-resource

AWS CLI

標記應用程式

下列 tag-resource 範例會標記應用程式資源。

aws appconfig tag-resource \ --resource-arn arn:aws:appconfig:us-east-1:682428703967:application/339ohji \ --tags '{"group1" : "1"}'

此命令不會產生輸出。

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 1:建立 AWS AppConfig 應用程式

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 TagResource

以下程式碼範例顯示如何使用 untag-resource

AWS CLI

從應用程式移除標籤

下列 untag-resource 範例會從指定的應用程式移除 group1 標籤。

aws appconfig untag-resource \ --resource-arn arn:aws:appconfig:us-east-1:111122223333:application/339ohji \ --tag-keys '["group1"]'

此命令不會產生輸出。

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 1:建立 AWS AppConfig 應用程式

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 UntagResource

以下程式碼範例顯示如何使用 update-application

AWS CLI

更新應用程式

下列 update-application 範例會更新指定應用程式的名稱。

aws appconfig update-application \ --application-id 339ohji \ --name "Example-Application"

輸出:

{ "Id": "339ohji", "Name": "Example-Application", "Description": "An application used for creating an example." }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 1:建立 AWS AppConfig 應用程式

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 UpdateApplication

以下程式碼範例顯示如何使用 update-configuration-profile

AWS CLI

更新組態設定檔

下列 update-configuration-profile 範例會更新指定組態設定檔的描述。

aws appconfig update-configuration-profile \ --application-id 339ohji \ --configuration-profile-id ur8hx2f \ --description "Configuration profile used for examples."

輸出:

{ "ApplicationId": "339ohji", "Id": "ur8hx2f", "Name": "Example-Configuration-Profile", "Description": "Configuration profile used for examples.", "LocationUri": "ssm-parameter://Example-Parameter", "RetrievalRoleArn": "arn:aws:iam::111122223333:role/Example-App-Config-Role" }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 3:建立組態和組態設定檔

以下程式碼範例顯示如何使用 update-deployment-strategy

AWS CLI

更新部署策略

下列 update-deployment-strategy 範例會將指定部署策略中的最終封裝時間更新為 20 分鐘。

aws appconfig update-deployment-strategy \ --deployment-strategy-id 1225qzk \ --final-bake-time-in-minutes 20

輸出:

{ "Id": "1225qzk", "Name": "Example-Deployment", "DeploymentDurationInMinutes": 15, "GrowthType": "LINEAR", "GrowthFactor": 25.0, "FinalBakeTimeInMinutes": 20, "ReplicateTo": "SSM_DOCUMENT" }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 4:建立部署策略

以下程式碼範例顯示如何使用 update-environment

AWS CLI

更新環境

下列 update-environment 範例會更新環境的描述。

aws appconfig update-environment \ --application-id 339ohji \ --environment-id 54j1r29 \ --description "An environment for examples."

輸出:

{ "ApplicationId": "339ohji", "Id": "54j1r29", "Name": "Example-Environment", "Description": "An environment for examples.", "State": "RolledBack" }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 2:建立環境

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 UpdateEnvironment

以下程式碼範例顯示如何使用 update-extension-association

AWS CLI

更新 AWS AppConfig 延伸模組關聯

下列 update-extension-association 範例會將新的參數值新增至 AWS AppConfig 中的延伸模組關聯。

aws appconfig update-extension-association \ --region us-west-2 \ --extension-association-id a1b2c3d4 \ --parameters S3bucket=FinanceMobileApp

輸出:

{ "Id": "a1b2c3d4", "ExtensionArn": "arn:aws:appconfig:us-west-2:123456789012:extension/S3-backup-extension/1", "ResourceArn": "arn:aws:appconfig:us-west-2:123456789012:application/Finance", "Parameters": { "S3bucket": "FinanceMobileApp" }, "ExtensionVersionNumber": 1 }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的使用 AWSAppConfig 延伸模組

以下程式碼範例顯示如何使用 update-extension

AWS CLI

更新 AWS AppConfig 延伸模組

下列 update-extension 範例會將額外的參數索引鍵新增至 AWS AppConfig 中的延伸模組。

aws appconfig update-extension \ --region us-west-2 \ --extension-identifier S3-backup-extension \ --parameters S3bucket={Required=true},CampaignID={Required=false}

輸出:

{ "Id": "1A2B3C4D", "Name": "S3-backup-extension", "VersionNumber": 1, "Arn": "arn:aws:appconfig:us-west-2:123456789012:extension/1A2B3C4D/1", "Actions": { "PRE_CREATE_HOSTED_CONFIGURATION_VERSION": [ { "Name": "S3backup", "Uri": "arn:aws:lambda:us-west-2:123456789012:function:S3backupfunction", "RoleArn": "arn:aws:iam::123456789012:role/appconfigextensionrole" } ] }, "Parameters": { "CampaignID": { "Required": false }, "S3bucket": { "Required": true } } }

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的使用 AWSAppConfig 延伸模組

  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 UpdateExtension

以下程式碼範例顯示如何使用 validate-configuration

AWS CLI

驗證組態

下列 validate-configuration 範例會使用組態設定檔中的驗證程式來驗證組態。

aws appconfig validate-configuration \ --application-id abc1234 \ --configuration-profile-id ur8hx2f \ --configuration-version 1

此命令不會產生輸出。

如需詳細資訊,請參閱《AWS AppConfig 使用者指南》中的步驟 3:建立組態和組態設定檔