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

[batch] Pass AWS_REGION by default to containers #10952

Closed
1 of 2 tasks
Dzhuneyt opened this issue Oct 19, 2020 · 5 comments · Fixed by #21041
Closed
1 of 2 tasks

[batch] Pass AWS_REGION by default to containers #10952

Dzhuneyt opened this issue Oct 19, 2020 · 5 comments · Fixed by #21041
Labels
@aws-cdk/aws-batch Related to AWS Batch effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Comments

@Dzhuneyt
Copy link
Contributor

Dzhuneyt commented Oct 19, 2020

Containers started through AWS Batch can't do even the most basic communication with other AWS services due to missing meaningful defaults.

Use Case

I've created an AWS Batch compute environment, queue and job definition. The job definition is very trivial - a NodeJS app that writes a row to DynamoDB. However, this trivial example fails with an error: UnhandledPromiseRejectionWarning: ConfigError: Missing region in config. That's because the AWS Batch container does not pass information about the current AWS region to the container, the same way it would pass it to the Lambda runtime, so the NodeJS app and the aws-sdk inside it, fails to connect to the DynamoDB service.

Proposed Solution

I usually solve this by passing the AWS_REGION as an environment variable to the container definition:

 new JobDefinition(this, 'app1', {
            container: {
                image: ContainerImage.fromAsset('./../apps/app1'),
                environment: {
                    AWS_REGION: Stack.of(this).region,
                },
            },
        });

This seems like something that can be embedded inside the JobDefinition construct to make life easy for developers that use this construct.

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@Dzhuneyt Dzhuneyt added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Oct 19, 2020
@github-actions github-actions bot added the @aws-cdk/aws-batch Related to AWS Batch label Oct 19, 2020
@iliapolo
Copy link
Contributor

@Dzhuneyt cool suggestion. Definitely open to a contribution here.

@iliapolo iliapolo added effort/small Small work item – less than a day of effort p2 and removed needs-triage This issue or PR still needs to be triaged. labels Oct 20, 2020
l0b0 added a commit to linz/geostore that referenced this issue Mar 29, 2021
Work around <aws/aws-cdk#10952> by injecting
`AWS_DEFAULT_REGION`.

Set up production table using
<pynamodb/PynamoDB#922 (comment)>.
l0b0 added a commit to linz/geostore that referenced this issue Mar 29, 2021
Work around <aws/aws-cdk#10952> by injecting
`AWS_DEFAULT_REGION`.

Set up production table using
<pynamodb/PynamoDB#922 (comment)>.
l0b0 added a commit to linz/geostore that referenced this issue Mar 30, 2021
Prepares for auto-generated table names.

Work around <aws/aws-cdk#10952> by injecting
`AWS_DEFAULT_REGION`.

Set up production table using
<pynamodb/PynamoDB#922 (comment)>.
kodiakhq bot added a commit to linz/geostore that referenced this issue Mar 30, 2021
Prepares for auto-generated table names.

Work around <aws/aws-cdk#10952> by injecting
`AWS_DEFAULT_REGION`.

Set up production table using
<pynamodb/PynamoDB#922 (comment)>.

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
@iliapolo iliapolo removed their assignment Jun 27, 2021
@github-actions
Copy link

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jun 28, 2022
@l0b0
Copy link
Contributor

l0b0 commented Jun 28, 2022

Ping.

@github-actions github-actions bot removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jun 28, 2022
@microbioticajon
Copy link

This would be very useful. Im currently using a framework that does not give me configurable access to the container definition. My golang sdks are not happy :-(

@mergify mergify bot closed this as completed in #21041 Jul 21, 2022
mergify bot pushed a commit that referenced this issue Jul 21, 2022
…r, if they are not explicitly set (#21041)

Closes #10952

----

### All Submissions:

* [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [X] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [X] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

comcalvi pushed a commit to comcalvi/aws-cdk that referenced this issue Jul 25, 2022
…r, if they are not explicitly set (aws#21041)

Closes aws#10952

----

### All Submissions:

* [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [X] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [X] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
josephedward pushed a commit to josephedward/aws-cdk that referenced this issue Aug 30, 2022
…r, if they are not explicitly set (aws#21041)

Closes aws#10952

----

### All Submissions:

* [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [X] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [X] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-batch Related to AWS Batch effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants