{"action":"created","issue":{"url":"https://api.github.com/repos/aws/aws-cli/issues/2862","repository_url":"https://api.github.com/repos/aws/aws-cli","labels_url":"https://api.github.com/repos/aws/aws-cli/issues/2862/labels{/name}","comments_url":"https://api.github.com/repos/aws/aws-cli/issues/2862/comments","events_url":"https://api.github.com/repos/aws/aws-cli/issues/2862/events","html_url":"https://github.com/aws/aws-cli/issues/2862","id":261310798,"number":2862,"title":"Generalize package functionality","user":{"login":"thinkerbot","id":7307,"avatar_url":"https://avatars1.githubusercontent.com/u/7307?v=4","gravatar_id":"","url":"https://api.github.com/users/thinkerbot","html_url":"https://github.com/thinkerbot","followers_url":"https://api.github.com/users/thinkerbot/followers","following_url":"https://api.github.com/users/thinkerbot/following{/other_user}","gists_url":"https://api.github.com/users/thinkerbot/gists{/gist_id}","starred_url":"https://api.github.com/users/thinkerbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thinkerbot/subscriptions","organizations_url":"https://api.github.com/users/thinkerbot/orgs","repos_url":"https://api.github.com/users/thinkerbot/repos","events_url":"https://api.github.com/users/thinkerbot/events{/privacy}","received_events_url":"https://api.github.com/users/thinkerbot/received_events","type":"User","site_admin":false},"labels":[{"id":502294270,"url":"https://api.github.com/repos/aws/aws-cli/labels/cloudformation%20package/deploy","name":"cloudformation package/deploy","color":"d93f0b","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-09-28T13:04:05Z","updated_at":"2017-10-02T17:19:42Z","closed_at":null,"author_association":"NONE","body":"I've found uses for packaging local artifacts in a variety of places that are unsupported by (and/or somewhat unrelated to) the `aws cloudformation package` command as it stands, for example:\r\n\r\n* uploading files for cfn-init\r\n* uploading docker images \r\n\r\nIt's lead me to think about how you could generalize, make extensible, and possibly simplify packaging. \r\n\r\n## Proposal\r\n\r\nDeclare artifacts in template Metadata, add resulting s3 attributes as default values on parameters. \r\n\r\n### Example\r\n\r\nBefore:\r\n\r\n```yaml\r\nMetadata:\r\n  AWS::Cloudformation::Package:\r\n    MyArtifact:\r\n       ArtifactType: s3\r\n       ParameterMapping:\r\n         MyS3Bucket: BucketName\r\n         MyS3Path: Path\r\n         MyS3URL: Url\r\n       Properties:\r\n         BucketName: bucketname\r\n         PathPrefix: prefix\r\n         LocalPath: ./path/to/dir_or_file\r\nParameters:\r\n    MyS3Bucket:\r\n      Type: String\r\n    MyS3Path:\r\n      Type: String\r\n    MyS3URL:\r\n      Type: String\r\nResources:\r\n# Use Ref as needed\r\n```\r\n\r\nAfter:\r\n\r\n```yaml\r\n# ...\r\nParameters:\r\n    MyS3Bucket:\r\n      Type: String\r\n      Default: bucketname\r\n    MyS3Path:\r\n      Type: String\r\n      Default: prefix/CHECKSUM\r\n    MyS3URL:\r\n      Type: String\r\n      Default: https://s3.amazonaws.com/bucketname/prefix/CHECKSUM\r\n# ...\r\n```\r\n\r\n### Rationale\r\n\r\nFrom a code perspective this ends up being easy; you don't have to support fields within specific resources. You simply look under the metadata, zip as needed, upload, and save the result as a parameter default. Then leave it to the user to use it wherever it is needed.  As a technical detail you'd have to support mapping S3 attributes since various forms of the S3 bucket/path/url are needed across resource types. \r\n\r\nThis approach would make packaging possible anywhere an s3 artifact can be used, including places where the s3 URL needs to be interpolated.  It is inherently forward compatible with all resource types that may be added in the future. I imagine it wouldn't be too hard to make it backwards compatible with the existing package behavior.  \r\n\r\nLastly I think it establishes a pattern for the general problem of \"upload a local artifact\". Extending the pattern to non-s3 artifacts like docker containers would be a matter of adding new artifact types. \r\n\r\n### Variations\r\n\r\nOne obvious variation would be to simply print out the parameter values rather than rewriting the template. Personally I like that approach as it would make packaging a transparent extension to a template, much like the use of Metadata for cfn-init. It would also solve issues that arise in rewriting, like #2757. \r\n"},"comment":{"url":"https://api.github.com/repos/aws/aws-cli/issues/comments/333602100","html_url":"https://github.com/aws/aws-cli/issues/2862#issuecomment-333602100","issue_url":"https://api.github.com/repos/aws/aws-cli/issues/2862","id":333602100,"user":{"login":"thinkerbot","id":7307,"avatar_url":"https://avatars1.githubusercontent.com/u/7307?v=4","gravatar_id":"","url":"https://api.github.com/users/thinkerbot","html_url":"https://github.com/thinkerbot","followers_url":"https://api.github.com/users/thinkerbot/followers","following_url":"https://api.github.com/users/thinkerbot/following{/other_user}","gists_url":"https://api.github.com/users/thinkerbot/gists{/gist_id}","starred_url":"https://api.github.com/users/thinkerbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thinkerbot/subscriptions","organizations_url":"https://api.github.com/users/thinkerbot/orgs","repos_url":"https://api.github.com/users/thinkerbot/repos","events_url":"https://api.github.com/users/thinkerbot/events{/privacy}","received_events_url":"https://api.github.com/users/thinkerbot/received_events","type":"User","site_admin":false},"created_at":"2017-10-02T17:19:42Z","updated_at":"2017-10-02T17:19:42Z","author_association":"NONE","body":"I hadn't thought about the way this would work for that use case, but you're right.  Might be a separate file really is the best way to do this -- kinda elegant to do it that way.  In that case packaging is a parameter assembly step.   You wouldn't even need write the output values into the template; they could be passed in just like any other parameter.\r\n\r\n"}}
{"actor":{"display_login":"thinkerbot"}}