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

feat(s3-deployment): allow ability to specify versionId for S3 bucket source #32484

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

nritholtz
Copy link

@nritholtz nritholtz commented Dec 11, 2024

Issue # (if applicable)

Closes #32462.

Reason for this change

Allow user to specify optional versionId of the zipped file for the s3 bucket source type.

Description of changes

  1. Added optional versionId to S3 Bucket source properties and new BucketSourceOptions interface.
  2. Changed the underlying CLI commands to use s3api get-object instead of aws cp to allow support of specifying versionId when supplied.

Description of how you validated changes

Added and updated appropriate unit/integration tests. Also needed to update solutionStackName: '64bit Amazon Linux 2023 v6.2.2 running Node.js 20', since no longer available.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 labels Dec 11, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team December 11, 2024 17:53
@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Dec 11, 2024
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@nritholtz nritholtz changed the title feat(aws-s3-deployment): allow ability to specify versionId for S3 bucket source feat(s3-deployment): allow ability to specify versionId for S3 bucket source Dec 11, 2024
@nritholtz nritholtz marked this pull request as ready for review December 12, 2024 02:28
@aws-cdk-automation aws-cdk-automation added the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Dec 12, 2024
@nritholtz nritholtz marked this pull request as draft December 12, 2024 16:21
@aws-cdk-automation aws-cdk-automation removed the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Dec 12, 2024
@aws-cdk-automation aws-cdk-automation dismissed their stale review December 12, 2024 18:24

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 4c0e0fb
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@nritholtz nritholtz marked this pull request as ready for review December 12, 2024 19:40
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Dec 12, 2024
@aws-cdk-automation
Copy link
Collaborator

This PR has been in the MERGE CONFLICTS state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.

Copy link
Contributor

@lpizzinidev lpizzinidev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the super-late review. Left comments for some minor adjustments👍

@@ -96,15 +113,19 @@ export class Source {
* @param bucket The S3 Bucket
* @param zipObjectKey The S3 object key of the zip file with contents
*/
public static bucket(bucket: s3.IBucket, zipObjectKey: string): ISource {
public static bucket(bucket: s3.IBucket, zipObjectKey: string, options?: BucketSourceOptions): ISource {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please update the documentation above and the related @example and @param?

Comment on lines +429 to +435
SourceVersionIds: cdk.Lazy.uncachedAny({
produce: () => {
const versionIds = this.sources.map(source => source.versionId ?? '');
// in the case where no version IDs supplied, then omit the property
return versionIds.some(versionId => versionId.length > 0) ? versionIds : [];
},
}, { omitEmptyArray: true } ),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SourceVersionIds: cdk.Lazy.uncachedAny({
produce: () => {
const versionIds = this.sources.map(source => source.versionId ?? '');
// in the case where no version IDs supplied, then omit the property
return versionIds.some(versionId => versionId.length > 0) ? versionIds : [];
},
}, { omitEmptyArray: true } ),
SourceVersionIds: cdk.Lazy.uncachedList({
produce: () => {
const versionIds = this.sources.map(source => source.versionId ?? '');
// in the case where no version IDs are supplied, then omit the property
return versionIds.some(versionId => versionId.length > 0) ? versionIds : [];
},
}, { omitEmpty: true } ),

Nit, uncachedList seems more appropriate.


const myBucketDeployment = new s3deploy.BucketDeployment(this, 'DeployMeWithVersioningSupport', {
sources: [s3deploy.Source.bucket(sourceBucket, 'object-key', {
versionId: '3sL4kqtJlcpXroDTDmJ+rmSpXd3dIbrHY+MTRCxf3vjVBH40Nr8X8gdRQBpUMLUo',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
versionId: '3sL4kqtJlcpXroDTDmJ+rmSpXd3dIbrHY+MTRCxf3vjVBH40Nr8X8gdRQBpUMLUo',
versionId: 'version-id',

Let's use a placeholder value.

Comment on lines +97 to +104
s3_source_zips = [
{
"BucketName": bucket,
"ObjectKey": object_key,
"VersionID": source_version_ids[i] if i < len(source_version_ids) else ""
}
for i, (bucket, object_key) in enumerate(zip(source_bucket_names, source_object_keys))
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
s3_source_zips = [
{
"BucketName": bucket,
"ObjectKey": object_key,
"VersionID": source_version_ids[i] if i < len(source_version_ids) else ""
}
for i, (bucket, object_key) in enumerate(zip(source_bucket_names, source_object_keys))
]
if not source_version_ids:
source_version_ids = [""] * len(source_bucket_names)
s3_source_zips = zip(source_bucket_names, source_object_keys, source_version_ids)
...
for i in range(len(s3_source_zips)):
s3_source_bucket, s3_source_key, s3_source_version_id = s3_source_zips[i]

Bit cleaner.

@aws-cdk-automation
Copy link
Collaborator

This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error.

@aws-cdk-automation aws-cdk-automation added the closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. label Feb 10, 2025
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 10, 2025
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Feb 10, 2025
@aaythapa aaythapa reopened this Feb 19, 2025
@aaythapa aaythapa added the pr-linter/do-not-close The PR linter will not close this PR while this label is present label Feb 19, 2025
@aaythapa
Copy link
Contributor

Hi @nritholtz thank you for opening this PR! Sorry about the late response. Looks like it got close because it was deemed that it was abandoned because there was some merge conflicts. Not that if the BUILD is failing or if there are merge conflicts then the PR won't show up on our board to review. I've re-opened the PR and if you're still working on it and can fix the conflicts then we'd be happy to take a look after. Thanks again for your contribution.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 pr-linter/do-not-close The PR linter will not close this PR while this label is present
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-s3-deployment): Allow ability to specify versionId for S3 bucket source
4 participants