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

--package argument for package-ci #143

Open
1 of 2 tasks
hauntingEcho opened this issue Oct 9, 2020 · 6 comments
Open
1 of 2 tasks

--package argument for package-ci #143

hauntingEcho opened this issue Oct 9, 2020 · 6 comments
Labels
feature-request A feature should be added or improved. module/cli-ext p3 This is a minor priority issue queued

Comments

@hauntingEcho
Copy link

hauntingEcho commented Oct 9, 2020

Describe the Feature

Currently, the only way to upload local code packages to S3 & transform the template is via package-ci. However, this may rebuild the artifact which may not be desired. Being able to upload local packages to S3 without rebuilding would add reliability to the build process.

An example workflow targeted by this change:

  1. CodePipeline A compiles the artifacts for a complex project (50 stacks with parameters for each others' outputs), via for x in */serverless.template; do (cd $(dirname ${x}) && dotnet lambda package --output-package out.zip); done;
  2. CodePipeline B deploys the artifacts to AWS account X, via for x in */serverless.template; do (cd $(dirname ${x}) && dotnet lambda package-ci); done; stacker build environments/dev.yml stacker.yml
  3. CodePipeline C deploys the artifacts to AWS account Y, via for x in */serverless.template; do (cd $(dirname ${x}) && dotnet lambda package-ci); done; stacker build environments/prod.yml stacker.yml

Is your Feature Request related to a problem?

When trying to deploy the same artifacts across multiple accounts, via a tool which manages dependencies between stacks (like stacker), code is likely to be recompiled rather than re-using the artifact. This can cause an issue if your deployment environment doesn't match your build environment, including e.g. access to private NuGet repositories

Proposed Solution

Add --package parameter to package-ci, matching its behavior in deploy-serverless and deploy-function

Describe alternatives you've considered

Making the S3 bucket readable by downstream accounts - this would allow a lower-security development environment to overwrite packages in use by the higher-security prod environment, rather than allowing prod to handle its own deployment/validation.

Another alternative would be to provide a separate action, which just does the template transformation but requires a pre-existing package.

Environment

AWS CodeBuild, running in AWS CodePipeline

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

It looks like all that's needed is to add the Package option to PackageCICommand's DefaultLocationOption config to match the implementation in DeployServerlessCommand


This is a 🚀 Feature Request

@hauntingEcho hauntingEcho added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Oct 9, 2020
@hauntingEcho
Copy link
Author

hauntingEcho commented Oct 9, 2020

for some clarification - codepipeline artifacts lose their access timestamps, which stops dotnet package's normal re-packaging detection/prevention from working

@github-actions
Copy link

We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.

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

The ability to re-use the same artifact across dev and prod environments, rather than having to rebuild them, is still needed

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

This needs to be reviewed with the team.

@hauntingEcho
Copy link
Author

hauntingEcho commented May 16, 2022

This can be worked around by using aws cloudformation package instead of dotnet lambda package-ci:

  1. build your template using AWS::Serverless::Function objects either using CodeUri directly or via the Globals. Set that CodeUri to a local zip path
  2. dotnet lambda package to build your zip file to that same local zip path
  3. use aws cloudformation package to handle the file uploads
  4. use aws cloudformation deploy to handle the actual deployment (or Stacker or a CodePipeline CloudFormation action or whatever)

Note that I think this will probably prevent you from using the Mock Lambda Test Tool

@ashishdhingra ashishdhingra added the p2 This is a standard priority issue label Dec 13, 2022
@normj
Copy link
Member

normj commented May 6, 2023

Unfortunately adding the --package switch doesn't work because there can be multiple packages needed if the cloudformation template is referring to multiple .NET projects. In order to to solve this we would need to pass in a map of zip files to lambda functions defined in the template.

The work around @hauntingEcho suggested about having the CodeUri point to a local zip file will also work with the dotnet lambda package-ci command.

@ashishdhingra ashishdhingra added p3 This is a minor priority issue queued and removed needs-review p2 This is a standard priority issue labels May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. module/cli-ext p3 This is a minor priority issue queued
Projects
None yet
Development

No branches or pull requests

3 participants