Skip to content

Commit

Permalink
AWS Replicator - regex match secretsmanager secrets based on their …
Browse files Browse the repository at this point in the history
…ARNs (#70)

Co-authored-by: Robert Lucian <[email protected]>
  • Loading branch information
robertlcx and RobertLucian authored Jul 17, 2024
1 parent ea21a52 commit 2f0ac6f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions aws-replicator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ localstack extensions install "git+https://github.com/localstack/localstack-exte

## Change Log

* `0.1.17`: Add basic support for ARN-based pattern-matching for `secretsmanager` resources
* `0.1.16`: Update imports for localstack >=3.6 compatibility
* `0.1.15`: Move localstack dependency installation to extra since it's provided at runtime
* `0.1.14`: Install missing dependencies into proxy container for localstack >=3.4 compatibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from localstack.constants import APPLICATION_JSON, LOCALHOST, LOCALHOST_HOSTNAME
from localstack.http import Response
from localstack.utils.aws import arns
from localstack.utils.aws.arns import sqs_queue_arn
from localstack.utils.aws.arns import secretsmanager_secret_arn, sqs_queue_arn
from localstack.utils.aws.aws_stack import get_valid_regions
from localstack.utils.aws.request_context import mock_aws_request_headers
from localstack.utils.collections import ensure_list
Expand Down Expand Up @@ -118,6 +118,12 @@ def _request_matches_resource(
if re.match(resource_name_pattern, candidate):
return True
return False
if service_name == "secretsmanager":
secret_id = context.service_request.get("SecretId") or ""
secret_arn = secretsmanager_secret_arn(
secret_id, account_id=context.account_id, region_name=context.region
)
return bool(re.match(resource_name_pattern, secret_arn))
# TODO: add more resource patterns
return True

Expand Down
2 changes: 1 addition & 1 deletion aws-replicator/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = localstack-extension-aws-replicator
version = 0.1.16
version = 0.1.17
summary = LocalStack Extension: AWS replicator
description = Replicate AWS resources into your LocalStack instance
long_description = file: README.md
Expand Down

0 comments on commit 2f0ac6f

Please sign in to comment.