Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix pipeline failure on terraform test failure #6855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions localstack/services/acm/provider.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from moto.acm import acm_backends
from moto.acm import models as acm_models

from localstack.aws.api import RequestContext, handler
Expand Down Expand Up @@ -66,7 +65,7 @@ def request_certificate(
response: RequestCertificateResponse = moto.call_moto(context)

cert_arn = response["CertificateArn"]
backend = acm_backends[context.account_id][context.region]
backend = acm_models.acm_backends[context.account_id][context.region]
cert = backend._certificates[cert_arn]
if not hasattr(cert, "domain_validation_options"):
cert.domain_validation_options = request.get("DomainValidationOptions")
Expand Down
6 changes: 3 additions & 3 deletions localstack/services/route53resolver/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ def delete_resolver_query_log_config_associations(
association_id = association.get("Id")
return self.resolver_query_log_config_associations.pop(association_id)

def get_or_create_firewall_config(self, resource_id, region, owner_id):
def get_or_create_firewall_config(self, resource_id: str, region: str, account_id: str):
"""returns the firewall config with the given id if it exists or creates a new one"""

validate_vpc(resource_id, region)
validate_vpc(resource_id, region, account_id)
firewall_config: FirewallConfig
if self.firewall_configs.get(resource_id):
firewall_config = self.firewall_configs[resource_id]
Expand All @@ -163,7 +163,7 @@ def get_or_create_firewall_config(self, resource_id, region, owner_id):
firewall_config = FirewallConfig(
Id=id,
ResourceId=resource_id,
OwnerId=owner_id,
OwnerId=account_id,
FirewallFailOpen="DISABLED",
)
self.firewall_configs[resource_id] = firewall_config
Expand Down
8 changes: 5 additions & 3 deletions localstack/services/route53resolver/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,9 @@ def create_resolver_query_log_config(
CreationTime=datetime.now(timezone.utc).isoformat(),
)
region_details.resolver_query_log_configs[id] = resolver_query_log_config
route53resolver_backends[context.region].tagger.tag_resource(arn, tags or [])
route53resolver_backends[context.account_id][context.region].tagger.tag_resource(
arn, tags or []
)
return CreateResolverQueryLogConfigResponse(
ResolverQueryLogConfig=resolver_query_log_config
)
Expand Down Expand Up @@ -665,7 +667,7 @@ def list_firewall_configs(
) -> ListFirewallConfigsResponse:
region_details = Route53ResolverBackend.get()
firewall_configs = []
backend = ec2_backends[context.region]
backend = ec2_backends[context.account_id][context.region]
for vpc in backend.vpcs:
if vpc not in region_details.firewall_configs:
region_details.get_or_create_firewall_config(
Expand All @@ -682,7 +684,7 @@ def update_firewall_config(
firewall_fail_open: FirewallFailOpenStatus,
) -> UpdateFirewallConfigResponse:
region_details = Route53ResolverBackend.get()
backend = ec2_backends[context.region]
backend = ec2_backends[context.account_id][context.region]
for resource_id in backend.vpcs:
if resource_id not in region_details.firewall_configs:
firewall_config = region_details.get_or_create_firewall_config(
Expand Down
4 changes: 2 additions & 2 deletions localstack/services/route53resolver/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def validate_destination_arn(destination_arn):
)


def validate_vpc(vpc_id, region):
backend = ec2_backends[region]
def validate_vpc(vpc_id: str, region: str, account_id: str):
backend = ec2_backends[account_id][region]

if vpc_id not in backend.vpcs:
raise ValidationException(
Expand Down
2 changes: 1 addition & 1 deletion tests/terraform/get-tf-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def print_test_names(service):
if len(tests) == 1:
print(tests[0])
else:
print('"(' + "|".join(tests) + ')"')
print('"(^' + "$|^".join(tests) + '$)"')


if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion tests/terraform/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -euo pipefail

export TF_ACC=1
export AWS_ALTERNATE_ACCESS_KEY_ID=test
Expand Down Expand Up @@ -52,4 +53,4 @@ fi

if [ $CI == "false" ]; then
python -m http.server
fi
fi
6 changes: 0 additions & 6 deletions tests/terraform/terraform-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ route53:
- TestAccRoute53Record_longTXTrecord
- TestAccRoute53Record_Allow_doNotOverwrite
- TestAccRoute53Record_Allow_overwrite
- TestAccRoute53VPCAssociationAuthorization_basic
- TestAccRoute53VPCAssociationAuthorization_disappears
- TestAccRoute53Zone_basic
- TestAccRoute53Zone_disappears
- TestAccRoute53Zone_multiple
Expand All @@ -53,7 +51,6 @@ route53:
- TestAccRoute53ZoneAssociation_disappears
- TestAccRoute53ZoneAssociation_Disappears_vpc
- TestAccRoute53ZoneAssociation_Disappears_zone
- TestAccRoute53ZoneAssociation_crossAccount
- TestAccRoute53ZoneAssociation_crossRegion
- TestAccRoute53QueryLog_basic
- TestAccRoute53QueryLog_disappears
Expand All @@ -73,11 +70,9 @@ route53resolver:
- TestAccRoute53ResolverEndpointDataSource_filter
- TestAccRoute53ResolverEndpoint_basicInbound
- TestAccRoute53ResolverEndpoint_updateOutbound
- TestAccRoute53ResolverFirewallConfig_basic
- TestAccRoute53ResolverFirewallConfig_disappears
- TestAccRoute53ResolverFirewallDomainList_basic
- TestAccRoute53ResolverFirewallDomainList_disappears
- TestAccRoute53ResolverFirewallDomainList_domains
- TestAccRoute53ResolverFirewallDomainList_tags
- TestAccRoute53ResolverFirewallRuleGroupAssociation_basic
- TestAccRoute53ResolverFirewallRuleGroupAssociation_disappears
Expand Down Expand Up @@ -242,7 +237,6 @@ s3:
- TestAccS3Bucket_disappears
- TestAccS3Bucket_Duplicate_basic
- TestAccS3Bucket_Duplicate_UsEast1
- TestAccS3Bucket_Duplicate_UsEast1AltAccount
- TestAccS3Bucket_Tags_basic
- TestAccS3Bucket_Tags_withNoSystemTags
- TestAccS3Bucket_Tags_ignoreTags
Expand Down