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

Confusion about File Assets and regions #171

Open
pedromtcosta opened this issue Jul 9, 2023 · 4 comments
Open

Confusion about File Assets and regions #171

pedromtcosta opened this issue Jul 9, 2023 · 4 comments

Comments

@pedromtcosta
Copy link

I defined the following structure for my Stack Set:

const app = new cdk.App();

const stack = new cdk.Stack(app);

new MyStackWithSharedResources(app, 'MyStackWithSharedResources');
const myMultiRegionStackSetStack = new MyMultiRegionStackSetStack(stack, 'MyMultiRegionStackSetStack');

new StackSet(stack, 'MyStackSet', {
  target: StackSetTarget.fromAccounts({
    accounts: ['11111111111'],
    regions: ['us-east-1'],
  }),
  template: StackSetTemplate.fromStackSetStack(myMultiRegionStackSetStack),
  capabilities: [
    Capability.IAM
  ],
  deploymentType: DeploymentType.selfManaged({
    adminRole: iam.Role.fromRoleArn(
      stack,
      'YoroiBackendZeroStackSetAdminRole',
      'arn:aws:iam::11111111111:role/AWSCloudFormationStackSetAdministrationRole',
    )
  })
});

when I try deploying it with cdk deploy --all, I get the error:

An Asset Bucket must be provided to use File Assets

Then I create a bucket on the eu-central-1 region and set the assetBucket on my StackSetStack:

export class MyMultiRegionStackSetStack extends StackSetStack {
  constructor(scope: Construct, id: string) {
    super(scope, id, {
      assetBucket: s3.Bucket.fromBucketArn(
        scope,
        'AssetBucket',
        'arn:aws:s3:::my-assets-bucket'
      )
    });
  }
}

but now I get the error:

Error occurred while GetObject. S3 Error Code: PermanentRedirect. S3 Error Message: The bucket is in this region: eu-central-1. Please use this region to retry the request

Changing my StackSet target to eu-central-1 fixes the problem, but it will simply come back when I start adding more regions.

How to get away from this situation where I cannot leave assetBucket empty because of the first error, but I also cannot set a value to it because the deployment will fail when I am in a different region than the bucket?

@corymhall
Copy link
Contributor

@josh-demuth

@josh-demuth
Copy link
Contributor

thank you for reporting this. we are working on a fix

@josh-demuth
Copy link
Contributor

this should be resolved by #325. we will update once we can get it merged.

@maherio
Copy link

maherio commented Oct 10, 2024

I'm getting a similar but slightly different error: PermanentRedirect. S3 Error Message: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint (frustratingly the logs/output don't actually specify what the endpoint should be).

Is it possible we're not formatting the s3 bucket endpoint up to current recommendations? i'm reading you should generally access a bucket by one of the following:

  • https://s3.amazonaws.com/<bucket name>
  • https://<bucket name>.s3.amazonaws.com

but it appears this is actually using https://s3.<bucket name>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants