Commit Graph

360 Commits

Author SHA1 Message Date
Don Kuntz
d2ce3a9e04
Flake8 fixes 2019-08-19 18:01:44 -05:00
Don Kuntz
4929298f1f
Test create_launch_template_version using launch_template id 2019-08-19 17:59:15 -05:00
Don Kuntz
a1aa087718
Add test for creating launch templates with TagSpecifications option 2019-08-19 17:58:19 -05:00
Don Kuntz
743e5be4d3
Confirm describe_launch_template_versions works with Versions, MinVersion, and MaxVersion options 2019-08-19 17:57:39 -05:00
Don Kuntz
1de63b1691 Specify region in launch template tests 2019-08-14 16:32:01 -05:00
Don Kuntz
aa3b6085d1 Add basic endpoints for EC2 Launch Templates
Specifically, add the CreateLaunchTemplate, CreateLaunchTemplateVersion,
DescribeLaunchTemplates, and DescribeLaunchTemplateVersions endpoints.
2019-08-14 16:11:07 -05:00
Don Kuntz
abf3db8d8a
Add a test to ensure that ec2.copy_image sets the proper owner id
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.
2019-07-22 21:57:15 -05:00
Don Kuntz
ce4059f6d9
Use a consistent owner id between EC2 resources
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.
2019-07-22 21:50:09 -05:00
Berislav Kovacki
e67e2deee4 Extend EC2 DescribeNetworkInterface filter support
* add description property to EC2 NetworkInterface
* extend DescribeNetworkInterfaces filter support with description,
subnet-id, private-ip-address attributes
2019-07-15 00:01:37 +02:00
acsbendi
7de0ef0f8b Fixed value is present in response even if it's None. 2019-07-05 15:24:16 +02:00
acsbendi
0b88dd1efb Fixed security group IDs not returned correctly. 2019-07-05 15:12:38 +02:00
acsbendi
7215b00466 Created test case for describe_instance_attribute. 2019-07-05 13:43:47 +02:00
Bendegúz Ács
8f53b16b9a Updates to create_subnet and describe_subnets responses (#2053)
* 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.
2019-05-28 16:33:25 +01:00
Bendegúz Ács
21917c4b93 Bug fix for default network ACL entries (#2056)
* 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.
2019-05-26 02:02:14 +01:00
Bendegúz Ács
f408709ef9 VPC IPv4 validation (#2026)
* Implemented throwing invalid subnet range error and fixed breaking tests.

* Implemented throwing invalid CIDR block parameter error for vpcs and subnets.

* Implemented throwing invalid destination CIDR block error.

* IPv6 addresses not accepted, strict checking disabled.

* Implemented throwing invalid subnet conflict error and fixed breaking tests.

* Implemented throwing invalid VPC range error and fixed breaking tests.

* Fixed accidentally removed ).

* Fixed test case trying to create two subnets with the same CIDR range.
2019-05-25 18:35:07 +01:00
David
868d0107bf Autoscaling instance azs (#2030)
* Add instance AZ support in autoscaling

* Resolve py36-py27 format string error in test_autoscaling
2019-05-25 11:18:16 +01:00
Daniel Miranda
fb2a76fd66 ec2: add support for creation and importing of real SSH keys (#2108)
* ec2: add support for creation and importing of real SSH keys

* setup: lock PyYAML version to avoid incompatibilities
2019-05-25 11:17:52 +01:00
Jeffery Smith
4a99dcddb2 Issue #2141 Adding owner-id to the filter for Snapshot (#2142)
* Adding owner-id to the filter for Snapshot
2019-05-25 10:34:59 +01:00
Hans
9b12ce6809 Fix #1842 Create cross region VPC peering connection in both region (#2195)
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
2019-05-25 10:21:57 +01:00
Mike Grima
d8dbc6a49c
Merge pull request #2134 from ogckw/master
Fix #2129 EC2 tag should raise ClientError when resource is empty
2019-04-17 11:05:28 -07:00
hsuhans
6b7282f93c Fix #2129 EC2 tag should raise ClientError when resource is empty
Raise MissingParameterError exception in models/validate_resource_ids of ec2.

Add ec2 create tag with empty resource test case.
Add ec2 delete tag with empty resource test case.

Related: #2129

Reference
boto3 create_tags
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.create_tags

boto3 delete_tags
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.delete_tags

Amazon EC2 API Reference Actions CreateTags
https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateTags.html

Amazon EC2 API Reference Actions DeleteTags
https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DeleteTags.html
2019-03-30 23:26:50 +08:00
Hugo Lopes Tavares
7c62f4a75c Add test to CloudFormation and PrimaryPrivateIpAddress GetAtt
This test would raise an error before d4e39146b7
2019-03-27 16:28:18 -04:00
Hugo Lopes Tavares
d4e39146b7 Make sure every NetworkInterface has a private IP
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)]
2019-03-27 16:27:10 -04:00
Tay Frost
15b3ede3cc Add test for case where ebs volume has no tags.
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.
2019-03-07 17:25:18 -05:00
Mike Grima
09855801ba
Merge pull request #2019 from acsbendi/launch_index
Correctly returning ami launch index
2019-02-25 12:16:40 -08:00
Mike Grima
d652755f3b
Merge pull request #2032 from drmorr0/spot_fleet_tag_specifications
tag specifications for spot fleet requests
2019-02-01 11:47:36 -08:00
David Morrison
b4b63202d9 tag specifications for spot fleet requests 2019-01-24 11:38:07 -08:00
acsbendi
68b8e6b636 Implemented adding default entries to default network ACLs. 2019-01-21 15:36:49 +01:00
acsbendi
3c5ce6c09e Fixed new subnets associated with a network ACL from a different VPC. 2019-01-21 13:30:22 +01:00
acsbendi
6bd7e5941f Added test case for running multiple instances in the same command. 2019-01-15 17:34:22 +01:00
Steve Pulec
93f68090e3
Merge pull request #1989 from jrbeilke/bugfix-ec2_ami_is-public
Bugfix for filtering EC2 AMIs with is-public (values should be lowercase)
2018-12-28 21:22:28 -05:00
Jon Beilke
a744adbcc5 AWS is case-sensitive when using is-public to filter for AMIs and expects lower-case values 2018-12-06 12:18:59 -06:00
Mark Challoner
6e6f23a1b0
Set deleted status on vpc peer deletion. 2018-11-14 14:48:57 +00:00
Jon Beilke
c1ebec1b35 remove start_time from attrib comparison in test_copy_snapshot() 2018-10-08 10:17:51 -05:00
hans
cedb89dc3b Fix #1830 Add support for cross-region VPC peering
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
2018-09-21 23:29:04 +08:00
Gary Donovan
2e5e7e7f5e Fix typo in test name (#1729) 2018-07-24 23:11:04 +01:00
Steve Pulec
b26d233820
Merge pull request #1565 from spulec/fix-1522
Fix security group rules for single rule case. Closes #1522.
2018-06-08 17:58:30 -04:00
Steve Pulec
96aba00242 Add freeze_time for ebs test. 2018-05-30 20:39:37 -04:00
zane
12188733b7 adding Address reallocate capability for EIP 2018-05-10 23:39:19 -07:00
Phil Christensen
ae2650ffc7 copy snapshot unit test 2018-04-15 17:08:54 -04:00
Steve Pulec
af8697c9a7 Fix security group rules for single rule case. Closes #1522. 2018-04-13 15:03:07 -04:00
Tom Elliff
e2af8bc836 Allow tagging snapshots on creation
Largely copying what was done for volume creation in https://github.com/spulec/moto/pull/1432
2018-04-04 17:46:51 +01:00
Rob Walker
4b3469292a Enable Extended CIDR Associations on VPC (#1511)
* 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
2018-03-21 09:10:38 -07:00
keirbadger
fecdf388c2 Add in filtering of EBS volumes on availability-zone (#1468) 2018-03-21 08:58:32 -07:00
Graham Lyons
5d51329c34 Don't create volumes for AMIs (#1456)
* 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.
2018-03-21 08:55:58 -07:00
Steve Pulec
924c99bcea
Merge pull request #1448 from grahamlyons/fix-ebs-tagging
Change `'image'` for `'volume'` when getting tags
2018-03-06 22:16:59 -05:00
Steve Pulec
6826b82cfb
Merge pull request #1455 from grahamlyons/snapshot-search-bug
Snapshot search bug
2018-03-06 22:06:33 -05:00
Hugo Lopes Tavares
5f61950096 Make SpotPrice optional when requesting a spot fleet
When price is omitted, AWS will default to the on-demand price
2018-02-01 18:07:35 -05:00
grahamlyons
f3debf8f6f Test and fix bug for snapshot searching
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.
2018-01-29 14:30:21 +00:00
grahamlyons
3ce57644cd Change 'image' for 'volume' when getting tags
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.
2018-01-26 11:12:50 +00:00