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

本文档仅适用于 AWS CLI 版本 1。有关 AWS CLI 版本 2 的相关文档,请参阅版本 2 用户指南

使用 AWS CLI 的 AWS AppConfig 示例

以下代码示例演示了如何通过将 AWS Command Line Interface与 AWS AppConfig 结合使用,来执行操作和实现常见场景。

操作是大型程序的代码摘录,必须在上下文中运行。您可以通过操作了解如何调用单个服务函数,还可以通过函数相关场景的上下文查看操作。

每个示例都包含一个指向完整源代码的链接,您可以从中找到有关如何在上下文中设置和运行代码的说明。

主题

操作

以下代码示例演示了如何使用 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 用户指南》中的使用 AWS AppConfig 扩展

以下代码示例演示了如何使用 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 用户指南》中的使用 AWS AppConfig 扩展

  • 有关 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 用户指南》中的使用 AWS AppConfig 扩展

以下代码示例演示了如何使用 delete-extension

AWS CLI

删除扩展

以下 delete-extension 示例删除 AWS AppConfig 中的扩展。

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

此命令不生成任何输出。

有关更多信息,请参阅《AWS AppConfig 用户指南》中的使用 AWS AppConfig 扩展

  • 有关 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 用户指南》中的使用 AWS AppConfig 扩展

以下代码示例演示了如何使用 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 用户指南》中的使用 AWS AppConfig 扩展

  • 有关 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 用户指南》中的使用 AWS AppConfig 扩展

以下代码示例演示了如何使用 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 用户指南》中的使用 AWS AppConfig 扩展

  • 有关 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 用户指南》中的使用 AWS AppConfig 扩展

以下代码示例演示了如何使用 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 用户指南》中的使用 AWS AppConfig 扩展

  • 有关 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:创建配置和配置文件