Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared snapshot copy uses source KMS not destination KMS #60

Open
ghost opened this issue Feb 12, 2020 · 3 comments
Open

Shared snapshot copy uses source KMS not destination KMS #60

ghost opened this issue Feb 12, 2020 · 3 comments

Comments

@ghost
Copy link

ghost commented Feb 12, 2020

I've just deployed the stacks in Source and Destination AWS accounts (separate accounts) and configured with KmsKeyDestination and KmsKeySource CMKs. Region in both accounts is eu-west-1.

I am surprised to see that the resultant local snapshot "copies" in the external (destination) account are encrypted with the KmsKeySource and haven't been re-encrypted with my specified KmsKeyDestination.

If I manually copy a shared snapshot I am able to specify the local CMK instead and the copy successfully uses it.

Anything I am missing? What should I look for? Anything I can try?

Thanks!

Karl

@ghost ghost changed the title Shared snapshot copies using source KMS not destination KMS Shared snapshot copy uses source KMS not destination KMS Feb 12, 2020
@ghost
Copy link
Author

ghost commented Feb 12, 2020

I did a bit of digging and altered the code in copy_local() to use _KMS_KEY_DEST_REGION in place of _KMS_KEY_SOURCE_REGION and I now get what I want/expect. It can't be this obvious though right?

def copy_local(snapshot_identifier, snapshot_object):
    client = boto3.client('rds', region_name=_REGION)

    tags = [{
            'Key': 'CopiedBy',
            'Value': 'Snapshot Tool for RDS'
        }]

    if snapshot_object['Encrypted']:
        logger.info('Copying encrypted snapshot %s locally' % snapshot_identifier)
        response = client.copy_db_snapshot(
            SourceDBSnapshotIdentifier = snapshot_object['Arn'],
            TargetDBSnapshotIdentifier = snapshot_identifier,
            KmsKeyId = _KMS_KEY_DEST_REGION, #_KMS_KEY_SOURCE_REGION,
            Tags = tags)

@mrcoronel
Copy link
Contributor

Hi Karl, I see what you mean... I suppose the behaviour should be different whether you are copying cross-region or not. In your case, it appears you are only copying cross-account.

It's a great catch! But the fix may be a bit more complicated. I'd want to make I do not break cross-account + cross-region.

Thanks!

@ghost
Copy link
Author

ghost commented Feb 13, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant