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

(aws-s3-deployment): Support include and exclude options for S3 sync #14362

Closed
1 of 2 tasks
davidtucker opened this issue Apr 24, 2021 · 6 comments · Fixed by #16054
Closed
1 of 2 tasks

(aws-s3-deployment): Support include and exclude options for S3 sync #14362

davidtucker opened this issue Apr 24, 2021 · 6 comments · Fixed by #16054
Labels
@aws-cdk/aws-s3-deployment effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@davidtucker
Copy link
Contributor

The aws-s3-deployment module currently does not support the include and exclude options that are available in the S3 sync command. By adding this, additional use cases can be supported.

Use Case

In my case, I have a single-page web app that uses a config file that is generated by a CloudFormation custom resource. I would like to leverage aws-s3-deployment for the deployment of the web application, but I want to ensure that the config file is not deleted when prune is set to true (although I do want all of the other files to be deleted).

Proposed Solution

By supporting the include and exclude properties for the S3 sync command with the aws-s3-deployment Lambda function, you can support this use case.

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

This is a 🚀 Feature Request

@davidtucker davidtucker added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Apr 24, 2021
@iliapolo
Copy link
Contributor

iliapolo commented May 3, 2021

I'm not sure I follow. Are you looking for the exclude flag to only be considered on delete?

Can you share a code snippet of how your use-case would be supported?

@iliapolo iliapolo added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label May 3, 2021
@github-actions
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label May 11, 2021
@davidtucker
Copy link
Contributor Author

I'll get a sample up for this early next week.

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels May 13, 2021
@iliapolo iliapolo added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed @aws-cdk/aws-s3 Related to Amazon S3 labels May 17, 2021
@davidtucker
Copy link
Contributor Author

In this case, it is common to generate config from the CDK that needs to be read at runtime by a web application (items that aren't yet known at synth time). With this being the case, I generally (and I have seen others do this as well) generate a file that is read at runtime (for the purposes of this example, I will call this config.js). This leads to the situation where you would want to leverage prune for the webapp, but yet also not remove the configuration file.

This can be accomplished with the AWS CLI by using either the exclude or include options for the s3 sync command. Thus, you could accomplish this with the following commands:

# build webapp
npm run build
# deploy webapp
aws s3 sync . s3://cdk-s3sync-test/
# generate config file (by whatever process)
# upload config file
aws s3 cp config.js s3://cdk-s3sync-test/
# redeploy webapp on change (doesn't delete config.js)
aws s3 sync . s3://cdk-s3sync-test/ --delete --exclude config.js

In terms of the CDK, I would like to see this work in the following manner:

new s3Deploy.BucketDeployment(this, 'WebAppDeploy', {
	// bundling options....
	prune: true,
	exclude: 'config.js'
});

Include could also be used for a similar effect. Since both options are supported in the AWS CLI, these could be added into the current process with minimal rework.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label May 18, 2021
@iliapolo
Copy link
Contributor

@davidtucker Thanks for the explanation, I understand what you mean now.

I am unassigning and marking this issue as p2, which means that we are unable to work on this immediately.

We use +1s to help prioritize our work, and are happy to revaluate this issue based on community feedback. You can reach out to the cdk.dev community on Slack to solicit support for reprioritization.

@iliapolo iliapolo added effort/medium Medium work item – several days of effort p2 and removed needs-triage This issue or PR still needs to be triaged. labels May 27, 2021
@iliapolo iliapolo removed their assignment May 27, 2021
@mergify mergify bot closed this as completed in #16054 Aug 19, 2021
mergify bot pushed a commit that referenced this issue Aug 19, 2021
This construct only enables integration with the two existing CLI options (`--exclude` and `--include`) that are supported for the `s3 sync` command. There are a few situations where this can prove valuable:

1. Situations where you want to deploy a subset of files from an archive - This can be handled by leveraging the bundling option for a source, although in some situations the `exclude` filter would be significantly easier.
2. Situations where you want to leverage `prune` but have specific files excluded - This is the situation that cannot be solved with current tools.  The most common scenario (and one I detailed in #14362 ) is where you manage a web app config file with a custom CloudFormation resource (to pass in API endpoint, user pool, etc...) and then manage a web application using this construct.  

Closes #14362 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️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.

smguggen pushed a commit to smguggen/aws-cdk that referenced this issue Aug 24, 2021
This construct only enables integration with the two existing CLI options (`--exclude` and `--include`) that are supported for the `s3 sync` command. There are a few situations where this can prove valuable:

1. Situations where you want to deploy a subset of files from an archive - This can be handled by leveraging the bundling option for a source, although in some situations the `exclude` filter would be significantly easier.
2. Situations where you want to leverage `prune` but have specific files excluded - This is the situation that cannot be solved with current tools.  The most common scenario (and one I detailed in aws#14362 ) is where you manage a web app config file with a custom CloudFormation resource (to pass in API endpoint, user pool, etc...) and then manage a web application using this construct.  

Closes aws#14362 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
hollanddd pushed a commit to hollanddd/aws-cdk that referenced this issue Aug 26, 2021
This construct only enables integration with the two existing CLI options (`--exclude` and `--include`) that are supported for the `s3 sync` command. There are a few situations where this can prove valuable:

1. Situations where you want to deploy a subset of files from an archive - This can be handled by leveraging the bundling option for a source, although in some situations the `exclude` filter would be significantly easier.
2. Situations where you want to leverage `prune` but have specific files excluded - This is the situation that cannot be solved with current tools.  The most common scenario (and one I detailed in aws#14362 ) is where you manage a web app config file with a custom CloudFormation resource (to pass in API endpoint, user pool, etc...) and then manage a web application using this construct.  

Closes aws#14362 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this issue Sep 6, 2021
This construct only enables integration with the two existing CLI options (`--exclude` and `--include`) that are supported for the `s3 sync` command. There are a few situations where this can prove valuable:

1. Situations where you want to deploy a subset of files from an archive - This can be handled by leveraging the bundling option for a source, although in some situations the `exclude` filter would be significantly easier.
2. Situations where you want to leverage `prune` but have specific files excluded - This is the situation that cannot be solved with current tools.  The most common scenario (and one I detailed in aws#14362 ) is where you manage a web app config file with a custom CloudFormation resource (to pass in API endpoint, user pool, etc...) and then manage a web application using this construct.  

Closes aws#14362 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
david-doyle-as24 pushed a commit to david-doyle-as24/aws-cdk that referenced this issue Sep 7, 2021
This construct only enables integration with the two existing CLI options (`--exclude` and `--include`) that are supported for the `s3 sync` command. There are a few situations where this can prove valuable:

1. Situations where you want to deploy a subset of files from an archive - This can be handled by leveraging the bundling option for a source, although in some situations the `exclude` filter would be significantly easier.
2. Situations where you want to leverage `prune` but have specific files excluded - This is the situation that cannot be solved with current tools.  The most common scenario (and one I detailed in aws#14362 ) is where you manage a web app config file with a custom CloudFormation resource (to pass in API endpoint, user pool, etc...) and then manage a web application using this construct.  

Closes aws#14362 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-s3-deployment effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants