From d0341f784495891682a266af71d707035748ab71 Mon Sep 17 00:00:00 2001 From: ford-at-aws Date: Thu, 2 Nov 2023 17:05:28 -0400 Subject: [PATCH 1/2] Removing hardcoded ENV in favor of config --- .tools/test/config/resources.yaml | 1 + .../consumer_stack/consumer_stack.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.tools/test/config/resources.yaml b/.tools/test/config/resources.yaml index c59c24fde3a..3ce0f4cf1ff 100644 --- a/.tools/test/config/resources.yaml +++ b/.tools/test/config/resources.yaml @@ -1,2 +1,3 @@ topic_name: "aws-weathertop-central-sns-fanout-topic" bucket_name: "aws-weathertop-central-log-bucket" +admin_acct: "808326389482" \ No newline at end of file diff --git a/.tools/test/sqs_lambda_to_batch_fargate/consumer_stack/consumer_stack.py b/.tools/test/sqs_lambda_to_batch_fargate/consumer_stack/consumer_stack.py index 627b47b1c93..d0cd5e03622 100644 --- a/.tools/test/sqs_lambda_to_batch_fargate/consumer_stack/consumer_stack.py +++ b/.tools/test/sqs_lambda_to_batch_fargate/consumer_stack/consumer_stack.py @@ -21,7 +21,6 @@ # Raises KeyError if environment variable doesn't exist. language_name = os.environ["LANGUAGE_NAME"] -producer_account_id = os.environ["PRODUCER_ACCOUNT_ID"] class ConsumerStack(Stack): @@ -30,6 +29,7 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None: resource_config = self.get_yaml_config("../config/resources.yaml") topic_name = resource_config["topic_name"] producer_bucket_name = resource_config["bucket_name"] + self.producer_account_id = resource_config["admin_acct"] sns_topic = self.init_get_topic(topic_name) sqs_queue = sqs.Queue(self, f"BatchJobQueue-{language_name}") self.init_subscribe_sns(sqs_queue, sns_topic) @@ -143,7 +143,7 @@ def init_subscribe_sns(self, sqs_queue, sns_topic): statement = iam.PolicyStatement() statement.add_resources(sqs_queue.queue_arn) statement.add_actions("sqs:*") - statement.add_arn_principal(f"arn:aws:iam::{producer_account_id}:root") + statement.add_arn_principal(f"arn:aws:iam::{self.producer_account_id}:root") statement.add_arn_principal(f"arn:aws:iam::{Aws.ACCOUNT_ID}:root") statement.add_condition("ArnLike", {"aws:SourceArn": sns_topic.topic_arn}) sqs_queue.add_to_resource_policy(statement) From 6a8745d503a409a9038b56242dd777c9ef7299db Mon Sep 17 00:00:00 2001 From: ford-at-aws Date: Thu, 2 Nov 2023 17:08:10 -0400 Subject: [PATCH 2/2] Removing hardcoded ENV in favor of config --- .tools/test/sqs_lambda_to_batch_fargate/README.md | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.tools/test/sqs_lambda_to_batch_fargate/README.md b/.tools/test/sqs_lambda_to_batch_fargate/README.md index 0ef57b9b2e9..ab90a8e9347 100644 --- a/.tools/test/sqs_lambda_to_batch_fargate/README.md +++ b/.tools/test/sqs_lambda_to_batch_fargate/README.md @@ -24,18 +24,6 @@ For example, if your language is Java, use: ``` export LANGUAGE_NAME=javav2 ``` - -Also, save the AWS account ID of the AWS account that is currently emitting -events for this stack to process. -``` -export PRODUCER_ACCOUNT_ID=12345678901 -``` - -Lastly, save the name of the SNS topic that will be producing the previously mentioned events. -If created using [this Producer CDK code](../eventbridge_rule_with_sns_fanout/README.md), it will look something like this: -``` -export FANOUT_TOPIC_NAME=ProducerStack-fanouttopic6EFF7954-pYvxBdNPbEWM -``` --- ## AWS CDK setup and deployment