使用 Route 53 配置文件示例 AWS CLI - AWS SDK代码示例

AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用 Route 53 配置文件示例 AWS CLI

以下代码示例向您展示了如何在 Route 53 配置文件中 AWS Command Line Interface 使用来执行操作和实现常见场景。

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

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

主题

操作

以下代码示例演示如何使用 associate-profile

AWS CLI

关联配置文件

以下associate-profile示例将配置文件关联到VPC。

aws route53profiles associate-profile \ --name test-association \ --profile-id rp-4987774726example \ --resource-id vpc-0af3b96b3example

输出:

{ "ProfileAssociation": { "CreationTime": 1710851336.527, "Id": "rpassoc-489ce212fexample", "ModificationTime": 1710851336.527, "Name": "test-association", "OwnerId": "123456789012", "ProfileId": "rp-4987774726example", "ResourceId": "vpc-0af3b96b3example", "Status": "CREATING", "StatusMessage": "Creating Profile Association" } }

有关更多信息,请参阅 Amazon Route 53 开发者指南中的使用配置文件

以下代码示例演示如何使用 associate-resource-to-profile

AWS CLI

将资源与配置文件关联

以下associate-resource-to-profile示例将优先级为 102 的DNS防火墙规则组与配置文件关联起来。

aws route53profiles associate-resource-to-profile \ --name test-resource-association \ --profile-id rp-4987774726example \ --resource-arn arn:aws:route53resolver:us-east-1:123456789012:firewall-rule-group/rslvr-frg-cfe7f72example \ --resource-properties "{\"priority\": 102}"

输出:

{ "ProfileResourceAssociation": { "CreationTime": 1710851216.613, "Id": "rpr-001913120a7example", "ModificationTime": 1710851216.613, "Name": "test-resource-association", "OwnerId": "123456789012", "ProfileId": "rp-4987774726example", "ResourceArn": "arn:aws:route53resolver:us-east-1:123456789012:firewall-rule-group/rslvr-frg-cfe7f72example", "ResourceProperties": "{\"priority\":102}", "ResourceType": "FIREWALL_RULE_GROUP", "Status": "UPDATING", "StatusMessage": "Updating the Profile to DNS Firewall rule group association" } }

以下代码示例演示如何使用 create-profile

AWS CLI

创建个人资料

以下create-profile示例创建了一个配置文件。

aws route53profiles create-profile \ --name test

输出:

{ "Profile": { "Arn": "arn:aws:route53profiles:us-east-1:123456789012:profile/rp-6ffe47d5example", "ClientToken": "2ca1a304-32b3-4f5f-bc4c-EXAMPLE11111", "CreationTime": 1710850903.578, "Id": "rp-6ffe47d5example", "ModificationTime": 1710850903.578, "Name": "test", "OwnerId": "123456789012", "ShareStatus": "NOT_SHARED", "Status": "COMPLETE", "StatusMessage": "Created Profile" } }

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

AWS CLI

删除个人资料

以下delete-profile示例删除了配置文件。

aws route53profiles delete-profile \ --profile-id rp-6ffe47d5example

输出:

{ "Profile": { "Arn": "arn:aws:route53profiles:us-east-1:123456789012:profile/rp-6ffe47d5example", "ClientToken": "0a15fec0-05d9-4f78-bec0-EXAMPLE11111", "CreationTime": 1710850903.578, "Id": "rp-6ffe47d5example", "ModificationTime": 1710850903.578, "Name": "test", "OwnerId": "123456789012", "ShareStatus": "NOT_SHARED", "Status": "DELETED", "StatusMessage": "Deleted Profile" } }

以下代码示例演示如何使用 disassociate-profile

AWS CLI

取消与配置文件的关联

以下disassociate-profile示例取消个人资料与的关联。VPC

aws route53profiles disassociate-profile \ --profile-id rp-4987774726example \ --resource-id vpc-0af3b96b3example

输出:

{ "ProfileAssociation": { "CreationTime": 1710851336.527, "Id": "rpassoc-489ce212fexample", "ModificationTime": 1710851401.362, "Name": "test-association", "OwnerId": "123456789012", "ProfileId": "rp-4987774726example", "ResourceId": "vpc-0af3b96b3example", "Status": "DELETING", "StatusMessage": "Deleting Profile Association" } }

以下代码示例演示如何使用 disassociate-resource-from-profile

AWS CLI

取消资源与配置文件的关联

以下disassociate-resource-from-profile示例取消DNS防火墙规则组与配置文件的关联。

aws route53profiles disassociate-resource-from-profile \ --profile-id rp-4987774726example \ --resource-arn arn:aws:route53resolver:us-east-1:123456789012:firewall-rule-group/rslvr-frg-cfe7f72example

输出:

{ "ProfileResourceAssociation": { "CreationTime": 1710851216.613, "Id": "rpr-001913120a7example", "ModificationTime": 1710852624.36, "Name": "test-resource-association", "OwnerId": "123456789012", "ProfileId": "rp-4987774726example", "ResourceArn": "arn:aws:route53resolver:us-east-1:123456789012:firewall-rule-group/rslvr-frg-cfe7f72example", "ResourceProperties": "{\"priority\":105}", "ResourceType": "FIREWALL_RULE_GROUP", "Status": "DELETING", "StatusMessage": "Deleting the Profile to DNS Firewall rule group association" } }

以下代码示例演示如何使用 get-profile-association

AWS CLI

获取有关个人资料关联的信息

以下内容get-profile-association返回有关指定配置文件关联的信息。

aws route53profiles get-profile-association \ --profile-association-id rpassoc-489ce212fexample

输出:

{ "ProfileAssociation": { "CreationTime": 1709338817.148, "Id": "rrpassoc-489ce212fexample", "ModificationTime": 1709338974.772, "Name": "test-association", "OwnerId": "123456789012", "ProfileId": "rp-4987774726example", "ResourceId": "vpc-0af3b96b3example", "Status": "COMPLETE", "StatusMessage": "Created Profile Association" } }

以下代码示例演示如何使用 get-profile-resource-association

AWS CLI

获取有关与配置文件关联的资源的信息

以下内容get-profile-resource-association返回有关与配置文件关联的指定资源的信息。

aws route53profiles get-profile-resource-association \ --profile-resource-association-id rpr-001913120a7example

输出:

{ "ProfileResourceAssociation": { "CreationTime": 1710851216.613, "Id": "rpr-001913120a7example", "ModificationTime": 1710852303.798, "Name": "test-resource-association", "OwnerId": "123456789012", "ProfileId": "rp-4987774726example", "ResourceArn": "arn:aws:route53resolver:us-east-1:123456789012:firewall-rule-group/rslvr-frg-cfe7f72example", "ResourceProperties": "{\"priority\":105}", "ResourceType": "FIREWALL_RULE_GROUP", "Status": "COMPLETE", "StatusMessage": "Completed creation of Profile to DNS Firewall rule group association" } }

以下代码示例演示如何使用 get-profile

AWS CLI

获取有关个人资料的信息

以下内容get-profile返回有关指定配置文件的信息。

aws route53profiles get-profile \ --profile-id rp-4987774726example

输出:

{ "Profile": { "Arn": "arn:aws:route53profiles:us-east-1:123456789012:profile/rp-4987774726example", "ClientToken": "0cbc5ae7-4921-4204-bea9-EXAMPLE11111", "CreationTime": 1710851044.288, "Id": "rp-4987774726example", "ModificationTime": 1710851044.288, "Name": "test", "OwnerId": "123456789012", "ShareStatus": "NOT_SHARED", "Status": "COMPLETE", "StatusMessage": "Created Profile" } }

以下代码示例演示如何使用 list-profile-associations

AWS CLI

列出个人资料关联

以下list-profile-associations列出了您 AWS 账户中的个人资料关联。

aws route53profiles list-profile-associations

输出:

{ "ProfileAssociations": [ { "CreationTime": 1709338817.148, "Id": "rpassoc-489ce212fexample", "ModificationTime": 1709338974.772, "Name": "test-association", "OwnerId": "123456789012", "ProfileId": "rp-4987774726example", "ResourceId": "vpc-0af3b96b3example", "Status": "COMPLETE", "StatusMessage": "Created Profile Association" } ] }

以下代码示例演示如何使用 list-profile-resource-associations

AWS CLI

列出配置文件资源关联

以下list-profile-resource-associations列出了指定配置文件的配置文件资源关联。

aws route53profiles list-profile-resource-associations \ --profile-id rp-4987774726example

输出:

{ "ProfileResourceAssociations": [ { "CreationTime": 1710851216.613, "Id": "rpr-001913120a7example", "ModificationTime": 1710851216.613, "Name": "test-resource-association", "OwnerId": "123456789012", "ProfileId": "rp-4987774726example", "ResourceArn": "arn:aws:route53resolver:us-east-1:123456789012:firewall-rule-group/rslvr-frg-cfe7f72example", "ResourceProperties": "{\"priority\":102}", "ResourceType": "FIREWALL_RULE_GROUP", "Status": "COMPLETE", "StatusMessage": "Completed creation of Profile to DNS Firewall rule group association" } ] }

以下代码示例演示如何使用 list-profiles

AWS CLI

列出个人资料

以下list-profiles列出了您 AWS 账户中的个人资料并显示了有关这些配置文件的其他信息。

aws route53profiles list-profiles

输出:

{ "ProfileSummaries": [ { "Arn": "arn:aws:route53profiles:us-east-1:123456789012:profile/rp-4987774726example", "Id": "rp-4987774726example", "Name": "test", "ShareStatus": "NOT_SHARED" } ] }

以下代码示例演示如何使用 list-tags-for-resource

AWS CLI

列出资源的标签

以下list-tags-for-resource列出了指定资源的标签。

aws route53profiles list-tags-for-resource \ --resource-arn arn:aws:route53profiles:us-east-1:123456789012:profile/rp-4987774726example

输出:

{ "Tags": { "my-key-2": "my-value-2", "my-key-1": "my-value-1" } }

以下代码示例演示如何使用 update-profile-resource-association

AWS CLI

更新与配置文件关联的资源

以下内容update-profile-resource-association更新了与配置文件关联的DNS防火墙规则组的优先级。

aws route53profiles update-profile-resource-association \ --profile-resource-association-id rpr-001913120a7example \ --resource-properties "{\"priority\": 105}"

输出:

{ "ProfileResourceAssociation": { "CreationTime": 1710851216.613, "Id": "rpr-001913120a7example", "ModificationTime": 1710852303.798, "Name": "test-resource-association", "OwnerId": "123456789012", "ProfileId": "rp-4987774726example", "ResourceArn": "arn:aws:route53resolver:us-east-1:123456789012:firewall-rule-group/rslvr-frg-cfe7f72example", "ResourceProperties": "{\"priority\":105}", "ResourceType": "FIREWALL_RULE_GROUP", "Status": "UPDATING", "StatusMessage": "Updating the Profile to DNS Firewall rule group association" } }