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

s3: bucketName could be available during synthesis #28971

Open
1 of 2 tasks
Rizxcviii opened this issue Feb 2, 2024 · 2 comments
Open
1 of 2 tasks

s3: bucketName could be available during synthesis #28971

Rizxcviii opened this issue Feb 2, 2024 · 2 comments
Labels
@aws-cdk/aws-s3 Related to Amazon S3 effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@Rizxcviii
Copy link
Contributor

Describe the feature

Give access for the S3 bucket to have it's name automatically be known during runtime, if bucketName was explicitly provided by the end user. Currently, a token is shown instead.

Use Case

If we are creating a new bucket, and this name would be needed later on, there seems to be a bit more spaghetti code required to try and send that bucket name to another construct later on, if needed rather immediately. A use case I'm working on currently is to deploy a list of buckets and assign them each glue tables.

export interface LakeformationStackProps extends StackProps {
  glueDatabases: {
    [bucketName: string]: glue.Database;
  };
}

I actually make use of the bucketName key, for both assigning to IDs' and to access within the runtime code (Accessing keys for for loops, etc.). I could have potentially used a list, followed by assigning the keys during synthesis, however a token is generated instead.
This is a rather arbitrary example, so unless this would be incredibly complex to develop, it might make sense to implement this change.

Proposed Solution

Allow it to be used during synthesis time, if the bucketName has explicitly been given by the developer.

Other Information

No response

Acknowledgements

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

CDK version used

2.121.1

Environment details (OS name and version, etc.)

Windows 11

@Rizxcviii Rizxcviii added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Feb 2, 2024
@github-actions github-actions bot added the @aws-cdk/aws-s3 Related to Amazon S3 label Feb 2, 2024
@pahud
Copy link
Contributor

pahud commented Feb 5, 2024

If you try to access the bucketName from its attribute bucketName, it would always be a token in the synth time even you explicitly specify it in the prop. I am afraid you will need to manage it in a list of your CDK code if you really need to use that.

@pahud pahud added p2 effort/medium Medium work item – several days of effort response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Feb 5, 2024
@Rizxcviii
Copy link
Contributor Author

Hey @pahud, I just looked through the code, and I see what you mean. It's a token, due to the bucketName being assigned to the physicalName, which is a huge hurdle, and (from my perspective) will probably be too much effort than it's worth to change.

My idea currently is to deprecate the bucketName for something like bucketNameV2, where the physicalName is no longer the bucket name, and all newly created buckets are generated different physicalNames. However, I'm going to assume that might not be the best approach?

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-s3 Related to Amazon S3 effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

2 participants