From 12899e9428ed691d36a8c102a3ce4a26e421a389 Mon Sep 17 00:00:00 2001 From: Bert Blommers Date: Tue, 12 Nov 2019 09:00:34 +0000 Subject: [PATCH 1/5] ChangeLog update for next version --- CHANGELOG.md | 183 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f42619b3..8413c796 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,189 @@ Moto Changelog =================== +1.3.14 +----- + + General Changes: + * Support for Python 3.8 + * Linting: Black is now enforced. + + New Services: + * Athena + * Config + * DataSync + * Step Functions + + New methods: + * Athena: + * create_work_group() + * list_work_groups() + * API Gateway: + * delete_stage() + * update_api_key() + * CloudWatch Logs + * list_tags_log_group() + * tag_log_group() + * untag_log_group() + * Config + * batch_get_resource_config() + * delete_aggregation_authorization() + * delete_configuration_aggregator() + * describe_aggregation_authorizations() + * describe_configuration_aggregators() + * describe_identity_pool() + * get_resource_config_history() + * list_aggregate_discovered_resources() (For S3) + * list_discovered_resources() (For S3) + * put_aggregation_authorization() + * put_configuration_aggregator() + * Cognito + * assume_role_with_web_identity() + * get_open_id_token() + * update_user_pool_domain() + * DataSync: + * cancel_task_execution() + * create_location() + * create_task() + * start_task_execution() + * EC2: + * create_launch_template() + * create_launch_template_version() + * describe_launch_template_versions() + * describe_launch_templates() + * ECS + * decrypt() + * encrypt() + * generate_data_key_without_plaintext() + * generate_random() + * re_encrypt() + * Glue + * batch_get_partition() + * IAM + * create_open_id_connect_provider() + * create_virtual_mfa_device() + * delete_account_password_policy() + * delete_open_id_connect_provider() + * delete_policy() + * delete_virtual_mfa_device() + * get_account_password_policy() + * get_open_id_connect_provider() + * list_open_id_connect_providers() + * list_virtual_mfa_devices() + * update_account_password_policy() + * Lambda + * create_event_source_mapping() + * delete_event_source_mapping() + * get_event_source_mapping() + * list_event_source_mappings() + * update_configuration() + * update_event_source_mapping() + * update_function_code() + * KMS + * decrypt() + * encrypt() + * generate_data_key_without_plaintext() + * generate_random() + * re_encrypt() + * SES + * send_templated_email() + * SNS + * add_permission() + * list_tags_for_resource() + * remove_permission() + * tag_resource() + * untag_resource() + * SSM + * describe_parameters() + * get_parameter_history() + * Step Functions + * create_state_machine() + * delete_state_machine() + * describe_execution() + * describe_state_machine() + * describe_state_machine_for_execution() + * list_executions() + * list_state_machines() + * list_tags_for_resource() + * start_execution() + * stop_execution() + SQS + * list_queue_tags() + * send_message_batch() + + General updates: + * API Gateway: + * Now generates valid IDs + * API Keys, Usage Plans now support tags + * ACM: + * list_certificates() accepts the status parameter + * Batch: + * submit_job() can now be called with job name + * CloudWatch Events + * Multi-region support + * CloudWatch Logs + * get_log_events() now supports pagination + * Cognito: + * Now throws UsernameExistsException for known users + * DynamoDB + * update_item() now supports lists, the list_append-operator and removing nested items + * delete_item() now supports condition expressions + * get_item() now supports projection expression + * Enforces 400KB item size + * Validation on duplicate keys in batch_get_item() + * Validation on AttributeDefinitions on create_table() + * Validation on Query Key Expression + * Projection Expressions now support nested attributes + * EC2: + * Change DesiredCapacity behaviour for AutoScaling groups + * Extend list of supported EC2 ENI properties + * Create ASG from Instance now supported + * ASG attached to a terminated instance now recreate the instance of required + * Unify OwnerIDs + * ECS + * Task definition revision deregistration: remaining revisions now remain unchanged + * Fix created_at/updated_at format for deployments + * Support multiple regions + * ELB + * Return correct response then describing target health of stopped instances + * Target groups now longer show terminated instances + * 'fixed-response' now a supported action-type + * Now supports redirect: authenticate-cognito + * Kinesis FireHose + * Now supports ExtendedS3DestinationConfiguration + * KMS + * Now supports tags + * Organizations + * create_organization() now creates Master account + * Redshift + * Fix timezone problems when creating a cluster + * Support for enhanced_vpc_routing-parameter + * Route53 + * Implemented UPSERT for change_resource_records + * S3: + * Support partNumber for head_object + * Support for INTELLIGENT_TIERING, GLACIER and DEEP_ARCHIVE + * Fix KeyCount attribute + * list_objects now supports pagination (next_marker) + * Support tagging for versioned objects + * STS + * Implement validation on policy length + * Lambda + * Support EventSourceMappings for SQS, DynamoDB + * get_function(), delete_function() now both support ARNs as parameters + * IAM + * Roles now support tags + * Policy Validation: SID can be empty + * Validate roles have no attachments when deleting + * SecretsManager + * Now supports binary secrets + * IOT + * update_thing_shadow validation + * delete_thing now also removed principals + * SQS + * Tags supported for create_queue() + + 1.3.7 ----- From de1bbf63987cdeb520a479dc1f8f98f25c6adc8a Mon Sep 17 00:00:00 2001 From: Steve Pulec Date: Thu, 14 Nov 2019 15:04:33 -0600 Subject: [PATCH 2/5] 1.3.14 --- moto/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moto/__init__.py b/moto/__init__.py index cbca726d..d32a9526 100644 --- a/moto/__init__.py +++ b/moto/__init__.py @@ -58,7 +58,7 @@ from .xray import XRaySegment, mock_xray, mock_xray_client # noqa # logging.getLogger('boto').setLevel(logging.CRITICAL) __title__ = "moto" -__version__ = "1.3.14.dev" +__version__ = "1.3.14" try: From f27a55f13fd99378847682a7778d95b45252afa6 Mon Sep 17 00:00:00 2001 From: Steve Pulec Date: Thu, 14 Nov 2019 15:10:54 -0600 Subject: [PATCH 3/5] Use Twine for publishing. --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ca028698..e84d036b 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,8 @@ aws_managed_policies: scripts/update_managed_policies.py upload_pypi_artifact: - python setup.py sdist bdist_wheel upload + python setup.py sdist bdist_wheel + twine upload dist/* push_dockerhub_image: docker build -t motoserver/moto . From 19a0d381e279cadae76c725987600730060c9c43 Mon Sep 17 00:00:00 2001 From: Steve Pulec Date: Thu, 14 Nov 2019 15:11:21 -0600 Subject: [PATCH 4/5] Bump version for prereleases. --- moto/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moto/__init__.py b/moto/__init__.py index d32a9526..767c0ee2 100644 --- a/moto/__init__.py +++ b/moto/__init__.py @@ -58,7 +58,7 @@ from .xray import XRaySegment, mock_xray, mock_xray_client # noqa # logging.getLogger('boto').setLevel(logging.CRITICAL) __title__ = "moto" -__version__ = "1.3.14" +__version__ = "1.3.15.dev" try: From cd0769af7e8ce293fea5c4aa84b4adfe50603626 Mon Sep 17 00:00:00 2001 From: Steven Reiling Date: Thu, 14 Nov 2019 14:07:04 -0800 Subject: [PATCH 5/5] Fix IAM instance profile tracking to reflect AWS's requirement for account-unique names --- moto/iam/models.py | 12 +++++++++--- tests/test_iam/test_iam.py | 8 ++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/moto/iam/models.py b/moto/iam/models.py index 2a76e912..1110da68 100644 --- a/moto/iam/models.py +++ b/moto/iam/models.py @@ -719,7 +719,7 @@ class AccountPasswordPolicy(BaseModel): def _format_error(self, key, value, constraint): return 'Value "{value}" at "{key}" failed to satisfy constraint: {constraint}'.format( - constraint=constraint, key=key, value=value, + constraint=constraint, key=key, value=value ) def _raise_errors(self): @@ -731,7 +731,7 @@ class AccountPasswordPolicy(BaseModel): raise ValidationError( "{count} validation error{plural} detected: {errors}".format( - count=count, plural=plural, errors=errors, + count=count, plural=plural, errors=errors ) ) @@ -1104,11 +1104,17 @@ class IAMBackend(BaseBackend): raise IAMNotFoundException("Policy not found") def create_instance_profile(self, name, path, role_ids): + if self.instance_profiles.get(name): + raise IAMConflictException( + code="EntityAlreadyExists", + message="Instance Profile {0} already exists.".format(name), + ) + instance_profile_id = random_resource_id() roles = [iam_backend.get_role_by_id(role_id) for role_id in role_ids] instance_profile = InstanceProfile(instance_profile_id, name, path, roles) - self.instance_profiles[instance_profile_id] = instance_profile + self.instance_profiles[name] = instance_profile return instance_profile def get_instance_profile(self, profile_name): diff --git a/tests/test_iam/test_iam.py b/tests/test_iam/test_iam.py index e0d8fdb8..8eea201d 100644 --- a/tests/test_iam/test_iam.py +++ b/tests/test_iam/test_iam.py @@ -169,6 +169,14 @@ def test_create_role_and_instance_profile(): profile.path.should.equal("/") +@mock_iam +def test_create_instance_profile_should_throw_when_name_is_not_unique(): + conn = boto3.client("iam", region_name="us-east-1") + conn.create_instance_profile(InstanceProfileName="unique-instance-profile") + with assert_raises(ClientError): + conn.create_instance_profile(InstanceProfileName="unique-instance-profile") + + @mock_iam_deprecated() def test_remove_role_from_instance_profile(): conn = boto.connect_iam()