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.

(aws-ec2): addS3DownloadCommand does not work in China, opt-in regions

See original GitHub issue

Use Case

Currently, AWS China region need aws s3 cp --region cn-north-1 to be able to download file from s3

https://github.com/aws/aws-cdk/blob/3530e8c758df3ea2fb26d654109e17a75f157b37/packages/%40aws-cdk/aws-ec2/lib/user-data.ts#L159

Proposed Solution

export interface S3DownloadOptions {

  /**
   * Name of the S3 bucket to download from
   */
  readonly bucket: IBucket;

  /**
   * The key of the file to download
   */
  readonly bucketKey: string;

  /**
   * The name of the local file.
   *
   * @default Linux   - /tmp/bucketKey
   *          Windows - %TEMP%/bucketKey
   */
  readonly localFile?: string;

  /**
   * The region to use
   */
  readonly region?: string;
}
  public addS3DownloadCommand(params: S3DownloadOptions): string {
    const s3Path = `s3://${params.bucket.bucketName}/${params.bucketKey}`;
    const localPath = ( params.localFile && params.localFile.length !== 0 ) ? params.localFile : `/tmp/${ params.bucketKey }`;
    this.addCommands(
      `mkdir -p $(dirname '${localPath}')`,
      `aws s3 cp --region '${params.region ?? stack.region}' '${s3Path}' '${localPath}'`,
    );

    return localPath;
  }
  • 👋 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:1
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rix0rrrcommented, Dec 14, 2020

I guess it’s only accidental that the other commands even work 😦 .

A better fix would have been to set AWS_REGION at the start of UserData, but that’s probably a change we can’t make anymore. Adding in the --region parameter seems like the best solution.

0reactions
github-actions[bot]commented, Jan 28, 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

Regions and Zones - Amazon Elastic Compute Cloud
Describes the Regions, Availability Zones, Local Zones, Outposts, and Wavelength Zones world-wide where you can host your instances.
Read more >
Is there way for users in china to access my s3, ec2 and api ...
Some days they can't. We are set up in 13 different AWS regions currently, and usually recommend users in China choose either our...
Read more >
@aws-cdk/aws-ec2 | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
Enabling Opt-In Regions - InsightCloudSec Docs
The screenshot below provides an example of how to enable the region in the AWS console. 1600. Enabling Opt-In Regions. Once enabled, you...
Read more >
Checking if a region is enabled using the AWS API. - Cloudar
“aws ec2 describe-regions” now returns the “OptInStatus”. ... region is enabled or not (except if you're using one of the China regions).
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