cloudformation-coverage-roadmap icon indicating copy to clipboard operation
cloudformation-coverage-roadmap copied to clipboard

AWS::S3::Object

Open benkehoe opened this issue 6 years ago • 1 comments

Instructions for CloudFormation Coverage New Issues Template

Quick Sample Summary:

  1. Title -> AWS::S3::Object
  2. Scope of request -> Add the ability to manage objects, like configuration, within CloudFormation templates
  3. Expected behavior -> I should be able to store object contents in JSON, YAML, text, or binary. I should be able to provide JSON and YAML objects as native CloudFormation (either JSON or YAML, and converting to my desired output format). Binary given as Base64. I should also be able to copy an object from another bucket.
  4. I should be able to write a YAML-formatted object from a JSON-formatted template.
  5. Links to existing API doc -> N/A
  6. Category tag -> Compute
  7. Additional context: This would allow the ability for configuration files to get written with references to a template, that can then get picked up at runtime by other users.

The ability to copy from another bucket would allow SAM to allow users to specify local paths and upload the files to a temporary bucket (along with code, etc.), and then CloudFormation could copy from there.

Example:

MyConfigObject:
  Type: AWS::S3::Object
  Properties:
    Bucket: !Ref TheBucket
    Key: /my/object/key
    Value:
      Json:
        Key: Value
        MyRef: !Ref SomeOtherResource

would write the following content:

{"Key":"Value","MyRef":"arn:aws:..."}
{
  "MyConfigObject": {
    "Type": "AWS::S3::Object",
    "Properties": {
      "Bucket": {"Ref": "TheBucket"},
      "Key": "/my/object/key",
      "Value": {
        "Yaml": {
          "Key": "Value",
          "MyRef": {"Ref": "SomeOtherResource"}
        }
      }
    }
  }
}

would write the following content:

Key: Value
MyRef: arn:aws:...

benkehoe avatar Aug 01 '19 15:08 benkehoe

There is a macro that helps with this issue to a degree. The macro converts the AWS::S3::Object into a custom resource which then uses lambda to add content into S3 however I agree this would be much better as a native object.

The AWS authored macro can be found here: https://github.com/aws-cloudformation/aws-cloudformation-templates/tree/main/CloudFormation/MacrosExamples/S3Objects

I actually have a newer version that uses crhelper which I adapted from this version and supports standard CloudFormation attributes such as DependsOn which is currently dropped by this version at the moment.

reidca avatar Oct 11 '24 13:10 reidca