Giter Club home page Giter Club logo

cloudformation-customization-demo's Introduction

###A Custom Provisioner for configuring S3 Bucket Transfer Acceleration

A provisioner for setting the S3 Bucket Accelerate Configuration Policy as part of a CloudFormation stack. Currently this attribute is not available within CloudFormation standard resources.

Provisioning the Provisioner

Generate the template: make all

Upload it to CloudFormation: make deploy

Using the Provisioner in another stack

A simple Node.js provisioner that runs in AWS Lambda. This stack can be used to add S3 Bucket Acceleration policies to S3 buckets created as part of Cloudformation stacks.

To set the Bucket Accelerate Policy as part of a Cloudformation Stack, an AWS Custom Object is used.

In Python, you can create the custom object with Troposphere

from troposphere.cloudformation import AWSCustomObject


class BucketAccelerateConfiguration(AWSCustomObject):
    resource_type = "Custom::CloudwatchEvent"
    props = {
        'ServiceToken': (basestring, True),
        'Status': (basestring, True),
        'Bucket': (basestring, True)
    }

You then simply need to instantiate the custom CloudFormation resource and add it to your template

from troposphere import Template, Ref
from troposphere.s3 import Bucket, PublicRead


t = Template()
s3bucket = Bucket(
    "MyS3Bucket",
    AccessControl=PublicRead
)
t.add_resource(s3bucket)

accelerate_configuration = BucketAccelerateConfiguration(
    "MyS3AccelerateConfiguration",
    ServiceToken='MyProvisionerLambdaFunctionArn',
    Status='Enabled',
    Bucket=Ref(s3bucket)
)
t.add_resource(accelerate_configuration)

ServiceToken: the ARN of the Lambda function provisioned by the stack created by this project Status: 'Enabled' or 'Suspended' Bucket: The S3 Bucket for which you are creating the policy. We pass a reference to the bucket, since we're creating it in the same stack

cloudformation-customization-demo's People

Watchers

Venkata Gummadi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.