diff --git a/.github/workflows/test_terraform.yml b/.github/workflows/test_terraform.yml index e7ea57d3a..015b88998 100644 --- a/.github/workflows/test_terraform.yml +++ b/.github/workflows/test_terraform.yml @@ -47,9 +47,9 @@ jobs: path: | ~/go/pkg/mod ~/.cache/go-build - key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ matrix.service }}-${{ hashFiles('**/tests/terraformtests/terraform-provider-aws/go.sum') }} + key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/tests/terraformtests/terraform-provider-aws/go.sum') }} restore-keys: | - ${{ runner.os }}-go-${{ matrix.go-version }}-${{ matrix.service }}- + ${{ runner.os }}-go-${{ matrix.go-version }}- - name: Get list of tests for this service id: get-list run: echo "::set-output name=testlist::$(python tests/terraformtests/get_tf_tests.py '${{ matrix.service }}')" diff --git a/moto/autoscaling/responses.py b/moto/autoscaling/responses.py index 924970565..608c29c15 100644 --- a/moto/autoscaling/responses.py +++ b/moto/autoscaling/responses.py @@ -137,6 +137,10 @@ class AutoScalingResponse(BaseResponse): template = self.response_template(DELETE_SCHEDULED_ACTION_TEMPLATE) return template.render() + def describe_scaling_activities(self): + template = self.response_template(DESCRIBE_SCALING_ACTIVITIES_TEMPLATE) + return template.render() + @amz_crc32 @amzn_request_id def attach_instances(self): @@ -883,6 +887,14 @@ DELETE_AUTOSCALING_GROUP_TEMPLATE = """ + + + + + +""" + DESCRIBE_AUTOSCALING_INSTANCES_TEMPLATE = """ diff --git a/moto/ce/models.py b/moto/ce/models.py index 77666d464..c4ea86823 100644 --- a/moto/ce/models.py +++ b/moto/ce/models.py @@ -3,6 +3,7 @@ from .exceptions import CostCategoryNotFound from moto.core import BaseBackend, BaseModel from moto.core.utils import BackendDict +from moto.utilities.tagging_service import TaggingService from moto.moto_api._internal import mock_random @@ -40,6 +41,7 @@ class CostExplorerBackend(BaseBackend): def __init__(self, region_name, account_id): super().__init__(region_name, account_id) self.cost_categories = dict() + self.tagger = TaggingService() def create_cost_category_definition( self, @@ -48,6 +50,7 @@ class CostExplorerBackend(BaseBackend): rules, default_value, split_charge_rules, + tags, ): """ The EffectiveOn and ResourceTags-parameters are not yet implemented @@ -61,6 +64,7 @@ class CostExplorerBackend(BaseBackend): split_charge_rules, ) self.cost_categories[ccd.arn] = ccd + self.tag_resource(ccd.arn, tags) return ccd.arn, "" def describe_cost_category_definition(self, cost_category_arn): @@ -90,6 +94,15 @@ class CostExplorerBackend(BaseBackend): return cost_category_arn, "" + def list_tags_for_resource(self, resource_arn): + return self.tagger.list_tags_for_resource(arn=resource_arn)["Tags"] + + def tag_resource(self, resource_arn, tags): + self.tagger.tag_resource(resource_arn, tags) + + def untag_resource(self, resource_arn, tag_keys): + self.tagger.untag_resource_using_names(resource_arn, tag_keys) + ce_backends = BackendDict( CostExplorerBackend, "ce", use_boto3_regions=False, additional_regions=["global"] diff --git a/moto/ce/responses.py b/moto/ce/responses.py index 5ba3b67cb..33a30f6ef 100644 --- a/moto/ce/responses.py +++ b/moto/ce/responses.py @@ -20,6 +20,7 @@ class CostExplorerResponse(BaseResponse): rules = params.get("Rules") default_value = params.get("DefaultValue") split_charge_rules = params.get("SplitChargeRules") + tags = params.get("ResourceTags") ( cost_category_arn, effective_start, @@ -29,6 +30,7 @@ class CostExplorerResponse(BaseResponse): rules=rules, default_value=default_value, split_charge_rules=split_charge_rules, + tags=tags, ) return json.dumps( dict(CostCategoryArn=cost_category_arn, EffectiveStart=effective_start) @@ -75,3 +77,23 @@ class CostExplorerResponse(BaseResponse): return json.dumps( dict(CostCategoryArn=cost_category_arn, EffectiveStart=effective_start) ) + + def list_tags_for_resource(self): + params = json.loads(self.body) + resource_arn = params.get("ResourceArn") + tags = self.ce_backend.list_tags_for_resource(resource_arn) + return json.dumps({"ResourceTags": tags}) + + def tag_resource(self): + params = json.loads(self.body) + resource_arn = params.get("ResourceArn") + tags = params.get("ResourceTags") + self.ce_backend.tag_resource(resource_arn, tags) + return json.dumps({}) + + def untag_resource(self): + params = json.loads(self.body) + resource_arn = params.get("ResourceArn") + tag_names = params.get("ResourceTagKeys") + self.ce_backend.untag_resource(resource_arn, tag_names) + return json.dumps({}) diff --git a/moto/elbv2/models.py b/moto/elbv2/models.py index ad0a92157..39c9f445a 100644 --- a/moto/elbv2/models.py +++ b/moto/elbv2/models.py @@ -525,6 +525,7 @@ class FakeLoadBalancer(CloudFormationModel): "load_balancing.cross_zone.enabled", "routing.http.desync_mitigation_mode", "routing.http.drop_invalid_header_fields.enabled", + "routing.http.preserve_host_header.enabled", "routing.http.x_amzn_tls_version_and_cipher_suite.enabled", "routing.http.xff_client_port.enabled", "routing.http2.enabled", diff --git a/tests/terraformtests/etc/0001-Patch-Hardcode-endpoints-to-local-server.patch b/tests/terraformtests/etc/0001-Patch-Hardcode-endpoints-to-local-server.patch index c1d8aebf9..7afe7f4e9 100644 --- a/tests/terraformtests/etc/0001-Patch-Hardcode-endpoints-to-local-server.patch +++ b/tests/terraformtests/etc/0001-Patch-Hardcode-endpoints-to-local-server.patch @@ -1,18 +1,8 @@ -From 91f2d9c33f241cb9dfb3700eaa739a46a06a29bc Mon Sep 17 00:00:00 2001 -From: Bert Blommers -Date: Wed, 29 Jun 2022 16:24:04 +0000 -Subject: [PATCH] Patch: Hardcode endpoints - ---- - internal/conns/config.go | 15 +++++++++++++++ - internal/provider/provider.go | 4 ++-- - 2 files changed, 17 insertions(+), 2 deletions(-) - diff --git a/internal/conns/config.go b/internal/conns/config.go -index 7bfd3100fd..b59083068a 100644 +index 13b7d153a7..1d981e9097 100644 --- a/internal/conns/config.go +++ b/internal/conns/config.go -@@ -78,8 +78,23 @@ type Config struct { +@@ -86,8 +86,23 @@ type Config struct { UseFIPSEndpoint bool } @@ -26,8 +16,8 @@ index 7bfd3100fd..b59083068a 100644 + return localEndpoints +} + - // Client configures and returns a fully initialized AWSClient - func (c *Config) Client(ctx context.Context) (interface{}, diag.Diagnostics) { + // ConfigureProvider configures the provided provider Meta (instance data). + func (c *Config) ConfigureProvider(ctx context.Context, client *AWSClient) (*AWSClient, diag.Diagnostics) { + + // XXX: added by bblommers + // insert custom endpoints @@ -37,19 +27,18 @@ index 7bfd3100fd..b59083068a 100644 AccessKey: c.AccessKey, APNInfo: StdUserAgentProducts(c.TerraformVersion), diff --git a/internal/provider/provider.go b/internal/provider/provider.go -index 7e6200d9ac..98d8c4fccc 100644 +index c49bd366d3..2db930e61d 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go -@@ -2082,14 +2082,14 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, terraformVer +@@ -2196,13 +2196,13 @@ func configure(ctx context.Context, provider *schema.Provider, d *schema.Resourc CustomCABundle: d.Get("custom_ca_bundle").(string), EC2MetadataServiceEndpoint: d.Get("ec2_metadata_service_endpoint").(string), EC2MetadataServiceEndpointMode: d.Get("ec2_metadata_service_endpoint_mode").(string), - Endpoints: make(map[string]string), + Endpoints: conns.GetLocalEndpoints(), // XXX: added by bblommers HTTPProxy: d.Get("http_proxy").(string), - IgnoreTagsConfig: expandProviderIgnoreTags(d.Get("ignore_tags").([]interface{})), Insecure: d.Get("insecure").(bool), - MaxRetries: d.Get("max_retries").(int), + MaxRetries: 25, // Set default here, not in schema (muxing with v6 provider). Profile: d.Get("profile").(string), Region: d.Get("region").(string), - S3UsePathStyle: d.Get("s3_use_path_style").(bool) || d.Get("s3_force_path_style").(bool), @@ -57,6 +46,3 @@ index 7e6200d9ac..98d8c4fccc 100644 SecretKey: d.Get("secret_key").(string), SkipCredsValidation: d.Get("skip_credentials_validation").(bool), SkipGetEC2Platforms: d.Get("skip_get_ec2_platforms").(bool), --- -2.25.1 - diff --git a/tests/terraformtests/terraform-provider-aws b/tests/terraformtests/terraform-provider-aws index 3c1f58b59..6020c871a 160000 --- a/tests/terraformtests/terraform-provider-aws +++ b/tests/terraformtests/terraform-provider-aws @@ -1 +1 @@ -Subproject commit 3c1f58b59a45aaecc9a4b243d5b1004283b3353b +Subproject commit 6020c871a99278bc855638a801e662328ab2b342 diff --git a/tests/terraformtests/terraform-tests.success.txt b/tests/terraformtests/terraform-tests.success.txt index cf9fcb3e0..e7af9d5de 100644 --- a/tests/terraformtests/terraform-tests.success.txt +++ b/tests/terraformtests/terraform-tests.success.txt @@ -177,7 +177,12 @@ kms: - TestAccKMSSecretsDataSource lambda: - TestAccLambdaAlias_ - - TestAccLambdaLayerVersion_ + - TestAccLambdaLayerVersion_basic + - TestAccLambdaLayerVersion_compatibleArchitectures + - TestAccLambdaLayerVersion_compatibleRuntimes + - TestAccLambdaLayerVersion_licenseInfo + - TestAccLambdaLayerVersion_s3 + - TestAccLambdaLayerVersion_update - TestAccLambdaFunctionURL meta: - TestAccMetaBillingServiceAccountDataSource diff --git a/tests/test_ce/test_ce_tags.py b/tests/test_ce/test_ce_tags.py new file mode 100644 index 000000000..a1ee5b43c --- /dev/null +++ b/tests/test_ce/test_ce_tags.py @@ -0,0 +1,55 @@ +import boto3 +import sure # noqa # pylint: disable=unused-import + +from moto import mock_ce + +# See our Development Tips on writing tests for hints on how to write good tests: +# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html + + +@mock_ce +def test_list_tags_if_none_exist(): + client = boto3.client("ce", region_name="ap-southeast-1") + arn = client.create_cost_category_definition( + Name="ccd", + RuleVersion="CostCategoryExpression.v1", + Rules=[ + {"Value": "v", "Rule": {"CostCategories": {"Key": "k", "Values": ["v"]}}} + ], + )["CostCategoryArn"] + + resp = client.list_tags_for_resource(ResourceArn=arn) + resp.should.have.key("ResourceTags").equals([]) + + client.tag_resource(ResourceArn=arn, ResourceTags=[{"Key": "t1", "Value": "v1"}]) + + resp = client.list_tags_for_resource(ResourceArn=arn) + resp.should.have.key("ResourceTags").equals([{"Key": "t1", "Value": "v1"}]) + + +@mock_ce +def test_cost_category_tags_workflow(): + client = boto3.client("ce", region_name="ap-southeast-1") + arn = client.create_cost_category_definition( + Name="ccd", + RuleVersion="CostCategoryExpression.v1", + Rules=[ + {"Value": "v", "Rule": {"CostCategories": {"Key": "k", "Values": ["v"]}}} + ], + ResourceTags=[{"Key": "t1", "Value": "v1"}], + )["CostCategoryArn"] + + resp = client.list_tags_for_resource(ResourceArn=arn) + resp.should.have.key("ResourceTags").equals([{"Key": "t1", "Value": "v1"}]) + + client.tag_resource(ResourceArn=arn, ResourceTags=[{"Key": "t2", "Value": "v2"}]) + + resp = client.list_tags_for_resource(ResourceArn=arn) + resp.should.have.key("ResourceTags").equals( + [{"Key": "t1", "Value": "v1"}, {"Key": "t2", "Value": "v2"}] + ) + + client.untag_resource(ResourceArn=arn, ResourceTagKeys=["t2"]) + + resp = client.list_tags_for_resource(ResourceArn=arn) + resp.should.have.key("ResourceTags").equals([{"Key": "t1", "Value": "v1"}])