使用 AWS CLI 的 Route 53 配置文件示例
以下代码示例演示了如何通过将 AWS Command Line Interface与 Route 53 配置文件结合使用,来执行操作和实现常见场景。
操作是大型程序的代码摘录,必须在上下文中运行。您可以通过操作了解如何调用单个服务函数,还可以通过函数相关场景的上下文查看操作。
每个示例都包含一个指向完整源代码的链接,您可以从中找到有关如何在上下文中设置和运行代码的说明。
主题
操作
以下代码示例演示如何使用 associate-profile
。
- AWS CLI
-
关联配置文件
以下
associate-profile
示例将配置文件关联到 VPC。aws route53profiles associate-profile \ --name
test-association
\ --profile-idrp-4987774726example
\ --resource-idvpc-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 开发人员指南》中的使用配置文件。
-
有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 AssociateProfile
。
-
以下代码示例演示如何使用 associate-resource-to-profile
。
- AWS CLI
-
将资源与配置文件关联
以下
associate-resource-to-profile
示例将优先级为 102 的 DNS 防火墙规则组与配置文件相关联。aws route53profiles associate-resource-to-profile \ --name
test-resource-association
\ --profile-idrp-4987774726example
\ --resource-arnarn: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" } }
-
有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 AssociateResourceToProfile
。
-
以下代码示例演示如何使用 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" } }
-
有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 CreateProfile
。
-
以下代码示例演示如何使用 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" } }
-
有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 DeleteProfile
。
-
以下代码示例演示如何使用 disassociate-profile
。
- AWS CLI
-
取消与配置文件的关联
以下
disassociate-profile
示例取消了配置文件与 VPC 的关联。aws route53profiles disassociate-profile \ --profile-id
rp-4987774726example
\ --resource-idvpc-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" } }
-
有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 DisassociateProfile
。
-
以下代码示例演示如何使用 disassociate-resource-from-profile
。
- AWS CLI
-
取消资源与配置文件的关联
以下
disassociate-resource-from-profile
示例取消了 DNS 防火墙规则组与配置文件的关联。aws route53profiles disassociate-resource-from-profile \ --profile-id
rp-4987774726example
\ --resource-arnarn: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" } }
-
有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 DisassociateResourceFromProfile
。
-
以下代码示例演示如何使用 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" } }
-
有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 GetProfileAssociation
。
-
以下代码示例演示如何使用 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" } }
-
有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 GetProfileResourceAssociation
。
-
以下代码示例演示如何使用 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" } }
-
有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 GetProfile
。
-
以下代码示例演示如何使用 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" } ] }
-
有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 ListProfileAssociations
。
-
以下代码示例演示如何使用 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" } ] }
-
有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 ListProfileResourceAssociations
。
-
以下代码示例演示如何使用 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" } ] }
-
有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 ListProfiles
。
-
以下代码示例演示如何使用 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" } }
-
有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 ListTagsForResource
。
-
以下代码示例演示如何使用 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" } }
-
有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 UpdateProfileResourceAssociation
。
-