AWS CLI を使用した Route 53 プロファイルの例 - AWS Command Line Interface

このドキュメントはバージョン 1 の AWS CLI のみを対象としています。AWS CLI のバージョン 2 に関連するドキュメントについては、バージョン 2 用ユーザーガイドを参照してください。

AWS CLI を使用した Route 53 プロファイルの例

次のコード例は、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 デベロッパーガイド」の「プロファイルの使用」を参照してください。

  • API の詳細については、「AWS CLI コマンドリファレンス」の「AssociateProfile」を参照してください。

次の例は、associate-resource-to-profile を使用する方法を説明しています。

AWS CLI

リソースをプロファイルに関連付けるには

次の associate-resource-to-profile の例では、DNS Firewall ルールグループを優先度 102 でプロファイルに関連付けます。

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" } }
  • 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-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" } }
  • API の詳細については、「AWS CLI コマンドリファレンス」の「DisassociateProfile」を参照してください。

次のコード例は、disassociate-resource-from-profile を使用する方法を示しています。

AWS CLI

プロファイルからリソースの関連付けを解除するには

次の disassociate-resource-from-profile の例では、プロファイルから DNS Firewall ルールグループの関連付けを解除します。

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" } }
  • 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" } ] }

次のコード例は、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 Firewall ルールグループの優先度を更新します。

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" } }