question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[batch] Pass AWS_REGION by default to containers

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
l0b0commented, Jun 28, 2022

Ping.

0reactions
github-actions[bot]commented, Jul 21, 2022

⚠️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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting up with AWS Batch
Setting up with AWS Batch · Sign up for AWS · Create an IAM user · Create IAM roles for your compute environments...
Read more >
Getting Started with AWS Batch
For Image, enter the name of the image that's used to launch the container. By default, all the images in the Docker Hub...
Read more >
Job definition parameters - AWS Batch
By default, AWS Batch enables the awslogs log driver. The valid values that are listed for this parameter are log drivers that the...
Read more >
AWS Batch Dos and Don'ts: Best Practices in a Nutshell
Use all Availability Zones in a Region enables Batch to tap into multiple instance pools and spread the risk of seeing interruptions.
Read more >
Creating a Simple “Fetch & Run” AWS Batch Job
AWS Batch executes jobs as Docker containers using Amazon ECS. You build a simple Docker image containing a helper application that can download ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found