Skip to content
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

Tools - Testing: Removing hardcoded ENV in favor of config #5610

Merged
merged 2 commits into from
Nov 2, 2023
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
1 change: 1 addition & 0 deletions .tools/test/config/resources.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
topic_name: "aws-weathertop-central-sns-fanout-topic"
bucket_name: "aws-weathertop-central-log-bucket"
admin_acct: "808326389482"
12 changes: 0 additions & 12 deletions .tools/test/sqs_lambda_to_batch_fargate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading