Commit Graph

425 Commits

Author SHA1 Message Date
Cat Cai
528cf0e21d Run black to fix linting 2019-11-12 14:51:31 -08:00
Cat Cai
9169b87748 Tests pass 2019-11-12 11:16:34 -08:00
Cat Cai
9cb105f5c2 Ensure test is sorted 2019-11-12 10:32:27 -08:00
Cat Cai
3398244f14 Fix styling problems 2019-11-11 12:09:52 -08:00
Wessel van der Veen
6d52cd06cb Adds support for enable/disable/describe vpc-classic-link-dns-support. 2019-11-11 10:55:09 -08:00
Wessel van der Veen
17cc46b91e adds basic support for vpc-classic-link 2019-11-11 10:54:36 -08:00
Bert Blommers
179bdd6caa #2002 - Take ElasticNetworkInterfaces into account when requesting available IP addresses 2019-11-08 16:40:17 +00:00
Asher Foa
96e5b1993d Run black on moto & test directories. 2019-10-31 10:36:05 -07:00
Chih-Hsuan Yen
18173a5951
Replace # flake8: noqa with # noqa
The former syntax is actually a mis-use and rejected since Flake8 3.6
[1].

[1] https://gitlab.com/pycqa/flake8/merge_requests/219
2019-10-27 20:41:22 +08:00
Stephan Huber
5a9c921d97 Merge remote-tracking branch 'upstream/master' 2019-08-30 14:39:29 +02:00
Stephan Huber
b94147a1d5 Merge remote-tracking branch 'upstream/master' 2019-08-30 14:18:01 +02:00
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
Stephan
d0de38601d Merge remote-tracking branch 'upstream/master' 2019-05-28 08:55:50 +02: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
Stephan
5804441d38 Merge remote-tracking branch 'upstream/master' 2019-04-29 12:11:47 +02: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
Stephan
e51d1bfade merge 2018-12-21 12:28:56 +01: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
Stephan Huber
0ba213ffcc Merge branch 'master' of https://github.com/spulec/moto into spulec-master 2018-10-16 15:29:56 +02: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
Jack Danger
4520cd930f
Merge pull request #1378 from william-richard/start-running-ami-tests
Make test_amis not executable, so nose runs it
2018-01-24 18:28:40 -08:00
dbfr3qs
597676c59c add tags when creating ebs volume 2018-01-15 21:52:32 +13:00
William Richard
09c5407b86
Fix tests that were introduced in PR #1398 2018-01-11 15:02:03 -05:00
William Richard
e0d4728c5d
Fix ami tests
- missing and malformed image ids
- test_ami_filters

- test_ami_copy tests

- test_ami_create_and_delete test

- test_ami_filter_wildcard test

- the rest of the tests by using the non-deprecated mock_ec2
2018-01-11 15:02:01 -05:00
William Richard
00a4249b74
Make test_amis not executable, so nose runs it
In trying to debug changes to the ami mock introduced in 1.1.25,
I noticed that the ami tests were not running.  Turns out that nose does not
run test files that are executable.

http://nose.readthedocs.io/en/latest/finding_tests.html

The ami test file was the only test file I could find that had the executable bit set.
2018-01-11 15:00:38 -05:00
Nuwan Goonasekera
56ce26a728 Added support for filtering AMIs by self (#1398)
* Added support for filtering AMIs by self

Closes: https://github.com/spulec/moto/issues/1396

* Adjusted regex to also match signature v4 and fixed py3 compatibility
2018-01-04 10:01:17 +00:00
Gordon Irving
4d9833b972 add test for descrie_regions with args 2017-12-28 21:02:58 +00:00
Nuwan Goonasekera
c68cd650e7 Make sure invalid or malformed AMIs raise an exception
Closes: https://github.com/spulec/moto/issues/1408
2017-12-22 18:50:22 +05:30
Archa91
474023f9a1 fix EC2 instances ebsOptimized not handled (#1340)
* fix EC2 instances ebsOptimized not handled

* add test_create_instance_ebs_optimized
2017-11-14 14:31:54 +00:00
Terry Cain
bd8c1e4567
adding owner id to amis v2 (#1331)
* Adding owner-id/OwnerId to the AMI classes to allow the value to be specified to test filtering images based on owner.

* Added default AMIs and filtering by owner-id

* Fixed some tests

* Fixed more random tests

* Updated MANIFEST

* .
2017-11-12 11:18:25 +00:00
Terry Cain
9ddf7fe436
Fixed some tests.
Some subnets were bogus so fixed that. Fixed issue where EC2-Classic was not respected.
RDS Deepcopy was breaking on subnet generator
2017-10-25 19:29:56 +01:00
Terry Cain
5b0e463554
Fixed a few ip issues
Fixes #1175
2017-10-24 23:57:43 +01:00
Terry Cain
f3623e3cd3 Fix for #1258 (#1260)
* Fix for #1258

* Updated doc link
2017-10-12 13:59:02 -07:00
William Johansson
88fb732302 Support wildcard tag filters on SecurityGroups 2017-10-06 21:55:01 +02:00
David Morrison
fa3268b7b7 fix tests 2017-10-06 08:07:21 -07:00
David Morrison
3d3d0e916e minor bugfixes and added tests 2017-10-05 18:46:58 -07:00
David Morrison
8ca7ccfcb5 add support for the modify_spot_fleet_request operation 2017-10-05 12:50:42 -07:00
Nuwan Goonasekera
5b01071bd4 Fix for regression in get_console_output() 2017-09-27 20:26:45 +05:30
Nuwan Goonasekera
ca56955a97 Added invalid id exceptions when filtering vpcs and subnets 2017-09-18 23:38:39 +05:30
Nuwan Goonasekera
08c4eff0b2 Added invalid id exceptions when filtering snapshots and volumes 2017-09-18 23:38:04 +05:30
Nuwan Goonasekera
298772ca92 Raise InvalidGroup.NotFound in DescribeSecurityGroups 2017-09-18 19:51:01 +05:30
Nuwan Goonasekera
0953ddde51 Fix for instance public ip not being cleared on eip disassociation 2017-09-16 12:26:43 +05:30
Jack Danger
b3ce255eee Merge pull request #1148 from gvlproject/vpc_address_filtering
Improved support for VPC Address filtering
2017-09-15 14:22:21 -07:00
Nuwan Goonasekera
8776129816 Improved support for VPC Address filtering 2017-09-16 01:49:57 +05:30
Nuwan Goonasekera
c116c57eb8 Ensure root device is listed in block device mappings 2017-09-15 21:30:32 +05:30
Nuwan Goonasekera
d0c610c5ac Added keypair filtering 2017-09-14 14:59:13 +05:30
Jack Danger
d2a234f75d falling back to use nic' 2017-09-08 16:30:21 -07:00
Jack Danger
5a03497367 rendering vpc_id in ec2 responses 2017-09-08 15:07:44 -07:00
Daniel Lutsch
1f6b1b8c4a Add list support to filters (#1083)
* initial pass with TODOs

* add list support to get_object_value

* fix group-id filters

* add tests for sg name and id filters
2017-08-25 23:43:29 -07:00
Daniel Lutsch
945b984538 Add private-dns-name filter and fix regional DNS (#1076)
* add private-dns-name to filter_dict_attribute_mapping

* add region_name attribute to Instance and InstanceResponse

* set dns name based on region

* test private-dns-name and network-interface.private-dns-name filters. checking both regional dns formats

* update test_ec2_classic_has_public_ip_address to use correct dns values
2017-08-23 01:39:50 -07:00
Christian Hellman
63b09eae13 Added DescribeAccountAttributes 2017-07-17 23:33:40 +00:00
Jeff Hardy
4e2f775c1f Use region list from Boto.
Boto can be configured with extra regions, but moto will fail to import
if they are not in the hardcoded list in ec2/models.py. Instead, use the
region list from boto to build the ec2_backends dict to ensure all
regions are available.
2017-05-26 12:47:28 -07:00
Jerome Bosman
b6d9b4f584 Replace and delete Network ACL Entries 2017-05-14 13:03:43 +01:00
Steve Pulec
97b920f6cf Fix ec2 tags in instance create. Closes #938. 2017-05-12 19:48:24 -04:00
Steve Pulec
0adebeed24 Merge #913. 2017-05-10 21:58:42 -04:00