AWS CLI で RDS Oracle のスナップショットを共有してみたメモ。
RDSのスナップショットを共有する
共有元AWSアカウント
- RDSのスナップショットを作成する
$ aws rds create-db-snapshot --db-snapshot-identifier oracle-ee-112-snapshot --db-instance-identifier oracle-ee-112
- スナップショットをAWSアカウントID「234567890123」に共有する
$ aws rds modify-db-snapshot-attribute --db-snapshot-identifier oracle-ee-112-snapshot --attribute-name restore --values-to-add 234567890123
共有先AWSアカウント
- 共有されたスナップショットを確認する。
$ aws rds describe-db-snapshots --include-shared --snapshot-type shared { "DBSnapshots": [ { "MasterUsername": "...", "LicenseModel": "...", "InstanceCreateTime": "2018-12-08T22:36:53.092Z", "Engine": "oracle-ee", "VpcId": "vpc-...", "DBSnapshotIdentifier": "arn:aws:rds:ap-northeast-1:123456789012:snapshot:oracle-ee-112-snapshot", "AllocatedStorage": 800, "Status": "available", "PercentProgress": 100, "DBSnapshotArn": "arn:aws:rds:ap-northeast-1:123456789012:snapshot:oracle-ee-112-snapshot", "EngineVersion": "11.2.0.4.v18", "ProcessorFeatures": [], "OptionGroupName": "default:oracle-ee-11-2", "SnapshotCreateTime": "2019-05-07T13:27:06.870Z", "AvailabilityZone": "ap-northeast-1a", "StorageType": "io1", "Encrypted": true, "IAMDatabaseAuthenticationEnabled": false, "KmsKeyId": "arn:aws:kms:ap-northeast-1:123456789012:key/...", "DbiResourceId": "db-...", "SnapshotType": "shared", "Iops": 40000, "Port": 1521, "DBInstanceIdentifier": "oracle-ee-112" } ] }
RDSのスナップショット共有をやめる
共有元AWSアカウント
- 共有をやめる
$ aws rds modify-db-snapshot-attribute --db-snapshot-identifier oracle-ee-112-snapshot --attribute-name restore --values-to-remove 234567890123
共有先AWSアカウント
- 共有されていないことを確認する
$ aws rds describe-db-snapshots --include-shared --snapshot-type shared { "DBSnapshots": [] }
補足
- スナップショット共有時の CloudTrail のイベント
{ "eventVersion": "1.05", "userIdentity": { "type": "AssumedRole", "principalId": "...", "arn": "arn:aws:sts::123456789012:assumed-role/EC2AdminRole/i-...", "accountId": "123456789012", "accessKeyId": "...", "sessionContext": { "attributes": { "mfaAuthenticated": "false", "creationDate": "2019-05-07T20:22:30Z" }, "sessionIssuer": { "type": "Role", "principalId": "...", "arn": "arn:aws:iam::123456789012:role/EC2AdminRole", "accountId": "123456789012", "userName": "EC2AdminRole" } } }, "eventTime": "2019-05-07T20:51:16Z", "eventSource": "rds.amazonaws.com", "eventName": "ModifyDBSnapshotAttribute", "awsRegion": "ap-northeast-1", "sourceIPAddress": "*.***.**.***", "userAgent": "aws-cli/1.16.86 Python/2.7.14 Linux/4.14.77-81.59.amzn2.x86_64 botocore/1.12.76", "requestParameters": { "dBSnapshotIdentifier": "oracle-ee-112-snapshot", "attributeName": "restore", "valuesToAdd": [ "234567890123" ] }, "responseElements": { "dBSnapshotIdentifier": "oracle-ee-112-snapshot", "dBSnapshotAttributes": [ { "attributeName": "restore", "attributeValues": [ "234567890123" ] } ] }, "requestID": "d85d6d41-dce1-4663-9c87-8c54f8a9fde8", "eventID": "34a0ff5a-97fc-4109-bba7-48616d255849", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }
- スナップショット共有削除時のイベント
{ "eventVersion": "1.05", "userIdentity": { "type": "AssumedRole", "principalId": "...:i-...", "arn": "arn:aws:sts::123456789012:assumed-role/EC2AdminRole/i-...", "accountId": "123456789012", "accessKeyId": "...", "sessionContext": { "attributes": { "mfaAuthenticated": "false", "creationDate": "2019-05-07T20:22:30Z" }, "sessionIssuer": { "type": "Role", "principalId": "...", "arn": "arn:aws:iam::123456789012:role/EC2AdminRole", "accountId": "123456789012", "userName": "EC2AdminRole" } } }, "eventTime": "2019-05-07T21:20:47Z", "eventSource": "rds.amazonaws.com", "eventName": "ModifyDBSnapshotAttribute", "awsRegion": "ap-northeast-1", "sourceIPAddress": "*.***.**.***", "userAgent": "aws-cli/1.16.86 Python/2.7.14 Linux/4.14.77-81.59.amzn2.x86_64 botocore/1.12.76", "requestParameters": { "dBSnapshotIdentifier": "oracle-ee-112-snapshot", "attributeName": "restore", "valuesToRemove": [ "234567890123" ] }, "responseElements": { "dBSnapshotIdentifier": "oracle-ee-112-snapshot", "dBSnapshotAttributes": [ { "attributeName": "restore", "attributeValues": [] } ] }, "requestID": "6ffbfd89-eeac-4e9f-b83e-815e13a586cd", "eventID": "8414b505-2360-4bda-b67a-5569685fc56b", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }
参考
固定オプションまたは永続オプションを含むオプショングループを使用する DB スナップショットを共有することはできません。固定オプションはオプショングループから削除できません。永続オプションを含むオプショングループは、そのオプショングループが DB インスタンスに割り当てられると、DB インスタンスから削除できなくなります。次の表は、固定オプションおよび永続オプションと、それらに関連する DB エンジンをリストしています。
DB のスナップショットの共有 - Amazon Relational Database Service