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

File Assets Error: The bucket is in this region: #159

Closed
johanbjorn opened this issue Jun 28, 2023 · 7 comments · Fixed by #325
Closed

File Assets Error: The bucket is in this region: #159

johanbjorn opened this issue Jun 28, 2023 · 7 comments · Fixed by #325

Comments

@johanbjorn
Copy link

johanbjorn commented Jun 28, 2023

With the following code:

`
app = App()

stack1 = Stack(
    app,
    "MyStackThu28jun611",
    env=Environment(region="eu-central-1", account="088713361256"),
)

bucket = Bucket(
    stack1,
    "Assets",
    bucket_name="cdkstacket-asset-bucket-28jun6",
    removal_policy=RemovalPolicy.DESTROY,
)
bucket.add_to_resource_policy(
    PolicyStatement(
        actions=["s3:Get*", "s3:List*"],
        resources=[bucket.arn_for_objects("*"), bucket.bucket_arn],
        principals=[OrganizationPrincipal("o-xxxxx")],
    )
)
for i in range(1, 3):
    stack = Stack(
        app,
        f"MyStackThu28jun6{i}",
    )
    devcontainer2_stack = Devcontainer(
        stack, f"Devcontainer2Stack2Thu28Jun1{i}", asset_bucket=bucket
    )
    StackSet(
        stack,
        f"StackSet2Thu28Jun{i}",
        capabilities=[Capability.NAMED_IAM],
        target=StackSetTarget.from_organizational_units(
            regions=["eu-central-1", "eu-west-1"],
            organizational_units=["r-nXXn"],
        ),
        deployment_type=DeploymentType.service_managed(),
        template=StackSetTemplate.from_stack_set_stack(devcontainer2_stack),
        operation_preferences=OperationPreferences(
            region_concurrency_type=RegionConcurrencyType.PARALLEL,
            max_concurrent_percentage=100,
            failure_tolerance_percentage=99,
        ),
    )
app.synth()`

I get this 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 "

If I remove "eu-west-1" from deploy_regions I don't get this error and deployment is successful.

@corymhall
Copy link
Contributor

@josh-demuth

@josh-demuth
Copy link
Contributor

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

@DaniDipp
Copy link

In the meantime, is there a workaround for this other than creating a separate single-region StackSet for each region?

@josh-demuth
Copy link
Contributor

unfortunately that is the guidance at this point where you would have a single stackset per region. thanks for your patience on the fix. this is prioritized and my goal is to have something up soon.

@juho9000
Copy link

What do you think about the approach taken here?

@juho9000
Copy link

@josh-demuth Any news?

@josh-demuth
Copy link
Contributor

thanks for your patience. PR just opened. what Philipp did was in line with what we were discussing as well.

@mergify mergify bot closed this as completed in #325 Feb 6, 2024
mergify bot pushed a commit that referenced this issue Feb 6, 2024
Fixes #159

Added support to use file assets across multiple regions in one stackset. This still requires to pass the asset bucket(s) to the construct. It also uses a bucket "prefix" which the stackset construct will append "-${region}" to the end of the bucket name. For example, all asset buckets across each region will need to have the same prefix like "assetbucket" and will need the region appended at the end "assetbucket-us-east-1" "assetbucket-us-west-2". it is out of scope of the construct to create these buckets at this time.
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

Successfully merging a pull request may close this issue.

5 participants