Ejemplo n.º 1
0
    def to_cloudformation_template(self):
        t = Template()
        t.description = self.description

        for d in self.dollops:
            d.to_cloudformation_template(t)
        return t
Ejemplo n.º 2
0
    def to_cloudformation_template(self):
        t = Template()
        t.description = self.description

        for d in self.dollops:
            d.to_cloudformation_template(t)
        return t
Ejemplo n.º 3
0
from os import path
from troposphere import AWS_REGION, Export, Join, Output, Parameter, Ref, Template, GetAtt
from troposphere.ec2 import InternetGateway, Route, RouteTable, Subnet, SubnetRouteTableAssociation, VPC, VPCGatewayAttachment, EIP, NatGateway

### Template Definition ###

template = Template()
template.description = "Hello world project VPC"

### Template Parameters ###

parameters = {}

parameters[ "Project" ] = template.add_parameter(Parameter(
    "Project",
    Type="String",
    Description="Project Name",
    Default="hello-world"))

### Template Resources ###

resources = {}

### VPC ###

resources[ "VPC" ] = template.add_resource(VPC(
    "VPC",
    CidrBlock = "10.0.0.0/24",
    EnableDnsHostnames = True,
    EnableDnsSupport = True,
    Tags = [ { "Key": "Name", "Value": Join("-", [ Ref(parameters[ "Project" ]), "vpc" ]) },
Ejemplo n.º 4
0
# Converted from EC2InstanceSample.template located at:
# http://aws.amazon.com/cloudformation/aws-cloudformation-templates/

from troposphere import Base64, FindInMap, GetAtt
from troposphere import Parameter, Output, Ref, Template
import troposphere.ec2 as ec2


template = Template()
template.description = "hallo ALLEMAAL"
template.add_version()

keyname_param = template.add_parameter(Parameter(
    "KeyName",
    Description="Name of an existing EC2 KeyPair to enable SSH "
                "access to the instance",
    Type="String",
))

template.add_mapping('RegionMap', {
    "us-east-1": {"AMI": "ami-7f418316"},
    "us-west-1": {"AMI": "ami-951945d0"},
    "us-west-2": {"AMI": "ami-16fd7026"},
    "eu-west-1": {"AMI": "ami-24506250"},
    "sa-east-1": {"AMI": "ami-3e3be423"},
    "ap-southeast-1": {"AMI": "ami-74dda626"},
    "ap-northeast-1": {"AMI": "ami-dcfa4edd"}
})

ec2_instance = template.add_resource(ec2.Instance(
    "Ec2Instance",
Ejemplo n.º 5
0
certificate_arn = 'arn:::::000000'
bucket_arn = 'arn:aws:s3:::example.application'

from troposphere import AWSAttribute, GetAtt, Join, Ref, Tags, Template
from troposphere.autoscaling import AutoScalingGroup, LaunchConfiguration, Metadata, ScalingPolicy
from troposphere.cloudformation import Init, InitConfig
from troposphere.cloudwatch import Alarm, MetricDimension
from troposphere.ec2 import SecurityGroup, SecurityGroupIngress
from troposphere.ec2 import Subnet, VPC
from troposphere.iam import InstanceProfile, Policy, PolicyType, Role
from troposphere.elasticloadbalancingv2 import LoadBalancer, TargetGroup, Listener, Action, Certificate, LoadBalancerAttributes, RedirectConfig
from troposphere.s3 import Bucket, BucketPolicy

# Set up the base template
template = Template()
template.description = "A simple load balanced application"
template.version = "2010-09-09"

# IAM Role and Policy for the Instance
example_role = Role("ExampleRole",
                    RoleName="ExampleRole",
                    AssumeRolePolicyDocument={
                        "AssumeRolePolicyDocument": {
                            "Version":
                            "2012-10-17",
                            "Statement": [{
                                "Effect": "Allow",
                                "Principal": {
                                    "Service": ["ec2.amazonaws.com"]
                                },
                                "Action": ["sts:AssumeRole"]
Ejemplo n.º 6
0
from troposphere import Base64, FindInMap, GetAtt
from troposphere import Parameter, Output, Ref, Template
import troposphere.ec2 as ec2
from troposphere.ec2 import Tag

def tag_resource(resource):
    resource.Tags = [
    project_tag
    ]

# The template
t = Template()
t.description = "Neptune test template"
t.add_version()

project_tag = Tag(Key="Project", Value="Neptune")

# NeptuneVpc
vpc = ec2.VPC("NeptuneVpc")
vpc.CidrBlock = "10.0.0.0/16"
tag_resource(vpc)
t.add_resource(vpc)    

# InternetGateway
igw = ec2.InternetGateway("InternetGateway")
tag_resource(igw)
t.add_resource(igw)

# InternetGatewayAttachment
igwa = ec2.VPCGatewayAttachment("InternetGatewayAttachment")
igwa.VpcId = vpc.ref()