This test is useful because before the last commit using copy_image
would not set the owner_id to the same one used when calling
describe_images.
For example, this code
conn = boto3.client("ec2")
copy_resp = conn.copy_image(
SourceImageId="ami-whatever",
...
)
describe_resp = conn.describe_images(
Owners=["self"]
)
Would result in describe_resp being empty, when it should contain the
image from the copy_resp before it.
By ensuring the owner ids are the same (see ce4059f6) the code example
now works as expected.
Previously there were a couple models which used different owner ids by
default, which could make tests relying on them fail if someone wasn't
expecting that. This change ensures a uniform owner id between
resources.
* Removed Tags field from create_subnet response.
* Added DefaultForAz to create_subnet response.
* Added MapPublicIpOnLaunch to create_subnet response.
* Added OwnerId to create_subnet response.
* Added AssignIpv6AddressOnCreation field for create_subnet and describe_subnet and implemented setting it in modify_subnet_attribute.
* Added SubnetArn to create_subnet response.
* Added AvailabilityZoneId to create_subnet and describe_subnet responses, and error for invalid availability zone.
* Added Ipv6CidrBlockAssociationSet to create_subnet response.
* Added missing fields to describe_subnets response.
* Added myself to list of contributors and marked describe_subnet as implemented.
* Fixed linting errors.
* Fixed blank line containing a tab.
* Fixed accidentally deleted ).
* Fixed broken tests.
* Fixed a bug where default network ACL entries could not be deleted.
* Implemented throwing error when a network entry with the same rule number and egress value already exists.
* Fixed syntax errors.
* Added socket.timeout to possibly raised exceptions in wait_for for Python 3.
Add a class level store in models/VPCPeeringConnectionBackend of ec2
for saving vpc peering connection.
Any instance can correctly save VPC peering connection info
on both region when it create vpc peering connection.
Update vpc_peering_connections in ec2/responses to meet new version:
DESCRIBE_VPC_PEERING_CONNECTIONS_RESPONSE,
ACCEPT_VPC_PEERING_CONNECTION_RESPONSE,
Previous code only create one region VPC peering connection but
doesn't create the other region VPC peering connection
when create cross region VPC peering connection.
Tested in real AWS environment at first
and create unit test case according to real AWS environment response.
Add 5 test cases
VPC cross region delete case
VPC cross region accept case
VPC cross region accept wrong region case
VPC cross region reject case
VPC cross region reject wrong region case
Related: #1842, #1830
AWS always assigns a primary IP address to Network Interfaces.
Using a test account (modified the IP):
>>> import boto
>>> vpc = boto.connect_vpc()
>>> eni = vpc.create_network_interface(subnet_id)
>>> eni.private_ip_addresses
[PrivateIPAddress(10.1.2.3, primary=True)]
This commit adds a test for a case where an EBS volume has no tags. When
an EBS volume has no tags, calls to the aws ec2 endpoints `create_volume`
and `describe_volumes` do not include the `Tags` key in the
`response.Volumes[]` object.
However, moto does include the `Tags` key in this case. This discrepancy
in behaviour can result in code passing a moto test but failing in
production.
Sample snippets that trigger this condition:
```
def create_volume_and_then_get_tags_from_response():
client = boto3.client('ec2', region_name='us-east-1')
volume_response = client.create_volume(
Size=10,
AvailabilityZone='us-east-1a'
)
keys = volume_response['Keys']
```
```
def create_volume_and_then_get_tags_from_describe_volumes():
client = boto3.client('ec2', region_name='us-east-1')
volume_response = client.create_volume(
Size=10,
AvailabilityZone='us-east-1a'
)
volume_describe_response = client.describe_volumes()
keys = volume_describe_response['Volumes'][0]['Keys']
```
Both sample snippets will succeed in a moto test, but fail with a
`KeyError` when using the aws api.
Add a class level store in models/VPCBackend of ec2
for saving vpcs of all regions info. Any instance can correctly find vpc in another region
when connecting vpc of cross-region or vpc of same region.
Modify vpc_peering_connections in ec2/responses to handle
vpc peering of same region or cross region.
Update vpc_peering_connections response
template content to latest (2016-11-15) .
Add vpc cross region peering successful test case.
Add vpc cross region peering fail test case.
Related: https://github.com/spulec/moto/issues/1830
Reference
CreateVpcPeeringConnection Sample Response
https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateVpcPeeringConnection.html
* Enable Extended CIDR Associations on VPC
* Ooops missed the utils, try to be more flakey?, remove unnecessary part in tests
* try to be even more flakey
* Delete the volume used during AMI creation
Creating an AMI doesn't actually result in the creation of an EBS
volume, although the associated snapshot does reference one. To that
end, delete the volume once we've used it.
* Add `owner_id` to `Snapshot`, verify AMI snapshots
The default AMIs which are created by moto have EBS volume mappings
but the snapshots associated with those don't have the correct
owners set.
This adds the owner to the snapshot model and passes it through from
the JSON data.
The logic which contructed a list of values for parameters with
multiple values was flawed in that e.g. `Subnet.1` and `Subnet.10`
would be have their values counted against `Subnet.1` because they
share a prefix.
This now checks for a starting `.` before counting that name as
having the requested prefix.
The AWS docs say that: "Currently, the resource types that support
tagging on creation are instance and volume." Calling `create_volume`
and passing `image` as the resource type in tag specifications causes
an `InvalidParameterValue` error.