-
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
117 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from .session import get_session, AioSession | ||
|
||
__all__ = ['get_session', 'AioSession'] | ||
__version__ = '1.3.0' | ||
__version__ = '1.3.1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from botocore.handlers import _get_presigned_url_source_and_destination_regions, \ | ||
_get_cross_region_presigned_url | ||
|
||
|
||
async def inject_presigned_url_ec2(params, request_signer, model, **kwargs): | ||
# The customer can still provide this, so we should pass if they do. | ||
if 'PresignedUrl' in params['body']: | ||
return | ||
src, dest = _get_presigned_url_source_and_destination_regions( | ||
request_signer, params['body']) | ||
url = await _get_cross_region_presigned_url( | ||
request_signer, params, model, src, dest) | ||
params['body']['PresignedUrl'] = url | ||
# EC2 Requires that the destination region be sent over the wire in | ||
# addition to the source region. | ||
params['body']['DestinationRegion'] = dest | ||
|
||
|
||
async def inject_presigned_url_rds(params, request_signer, model, **kwargs): | ||
# SourceRegion is not required for RDS operations, so it's possible that | ||
# it isn't set. In that case it's probably a local copy so we don't need | ||
# to do anything else. | ||
if 'SourceRegion' not in params['body']: | ||
return | ||
|
||
src, dest = _get_presigned_url_source_and_destination_regions( | ||
request_signer, params['body']) | ||
|
||
# Since SourceRegion isn't actually modeled for RDS, it needs to be | ||
# removed from the request params before we send the actual request. | ||
del params['body']['SourceRegion'] | ||
|
||
if 'PreSignedUrl' in params['body']: | ||
return | ||
|
||
url = await _get_cross_region_presigned_url( | ||
request_signer, params, model, src, dest) | ||
params['body']['PreSignedUrl'] = url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import pytest | ||
|
||
|
||
@pytest.mark.moto | ||
@pytest.mark.asyncio | ||
async def test_ec2_snapshot(ec2_client): | ||
# TODO: this needs to somehow validate the presigned url sent because moto is not | ||
volume_response = await ec2_client.create_volume( | ||
AvailabilityZone="us-east-1", Size=10) | ||
tag_spec = [ | ||
{"ResourceType": "snapshot", "Tags": [{"Key": "key", "Value": "value"}]} | ||
] | ||
|
||
create_snapshot_response = await ec2_client.create_snapshot( | ||
VolumeId=volume_response["VolumeId"], TagSpecifications=tag_spec | ||
) | ||
|
||
copy_snapshot_response = await ec2_client.copy_snapshot( | ||
SourceSnapshotId=create_snapshot_response["SnapshotId"], | ||
SourceRegion="us-east-1", | ||
DestinationRegion="us-east-1", | ||
Encrypted=True, | ||
TagSpecifications=tag_spec, | ||
KmsKeyId="key-1234", | ||
) | ||
|
||
assert copy_snapshot_response['SnapshotId'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters