Exemplo n.º 1
0
                                         to_port=22,
                                         cidr_blocks=['0.0.0.0/0']),
        aws.ec2.SecurityGroupIngressArgs(protocol='tcp',
                                         from_port=80,
                                         to_port=80,
                                         cidr_blocks=['0.0.0.0/0']),
    ],
)

# Get the AMI
ami = aws.get_ami(
    owners=['amazon'],
    most_recent=True,
    filters=[
        aws.GetAmiFilterArgs(
            name='name',
            values=['amzn2-ami-hvm-2.0.????????-x86_64-gp2'],
        )
    ],
)

# Create an EC2 server that we'll then provision stuff onto.
size = 't2.micro'
if key_name is None:
    key = aws.ec2.KeyPair('key', public_key=public_key)
    key_name = key.key_name
server = aws.ec2.Instance(
    'server',
    instance_type=size,
    ami=ami.id,
    key_name=key_name,
    vpc_security_group_ids=[secgrp.id],
Exemplo n.º 2
0
"""A Python Pulumi program"""

import pulumi
import pulumi_aws as aws

size = 't2.micro'

ami = aws.get_ami(
    most_recent=True,
    owners=["137112412989"],
    filters=[aws.GetAmiFilterArgs(name="name", values=["amzn-ami-hvm-*"])])

group = aws.ec2.SecurityGroup('web-secgrp',
                              description='Enable HTTP access',
                              ingress=[
                                  aws.ec2.SecurityGroupIngressArgs(
                                      protocol='tcp',
                                      from_port=80,
                                      to_port=80,
                                      cidr_blocks=['0.0.0.0/0'],
                                  )
                              ])

user_data = """
#!/bin/bash
echo "Hello, World!" > index.html
nohup python -m SimpleHTTPServer 80 &
"""

server = aws.ec2.Instance('web-server-www',
                          instance_type=size,
Exemplo n.º 3
0
import pulumi
import pulumi_aws as aws

# Create a new security group for port 80.
security_group = aws.ec2.SecurityGroup("securityGroup",
                                       ingress=[
                                           aws.ec2.SecurityGroupIngressArgs(
                                               protocol="tcp",
                                               from_port=0,
                                               to_port=0,
                                               cidr_blocks=["0.0.0.0/0"],
                                           )
                                       ])
ami = aws.get_ami(filters=[
    aws.GetAmiFilterArgs(
        name="name",
        values=["amzn-ami-hvm-*-x86_64-ebs"],
    )
],
                  owners=["137112412989"],
                  most_recent=True)
# Create a simple web server using the startup script for the instance.
server = aws.ec2.Instance("server",
                          tags={
                              "Name": "web-server-www",
                          },
                          instance_type="t2.micro",
                          security_groups=[security_group.name],
                          ami=ami.id,
                          user_data="""#!/bin/bash
echo "Hello, World!" > index.html
nohup python -m SimpleHTTPServer 80 &
Exemplo n.º 4
0
import pulumi
import pulumi_aws as aws

ubuntu = aws.get_ami(filters=[
    aws.GetAmiFilterArgs(
        name="name",
        values=["ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*"],
    ),
    aws.GetAmiFilterArgs(
        name="virtualization-type",
        values=["hvm"],
    ),
],
                     most_recent=True,
                     owners=["099720109477"])
web = aws.ec2.Instance("web",
                       ami=ubuntu.id,
                       instance_type="t2.micro",
                       tags={
                           "Name": "HelloWorld",
                       })
instance_type = config.require("instance_type")
node_db_volume_size = int(config.require("node_db_volume_size"))
node_chain = config.require("node_chain")
ssh_public_key = config.require("ssh_public_key")
stack_name = pulumi.get_stack()

# setting ssh key
ssh_key = aws.ec2.KeyPair("pulumi01", public_key=ssh_public_key)

# choosing the latest ubuntu minimal 20.04 image
ubuntu_minimal = aws.get_ami(
    most_recent=True,
    filters=[
        aws.GetAmiFilterArgs(
            name="name",
            values=[
                "ubuntu-minimal/images/hvm-ssd/ubuntu-focal-20.04-amd64-minimal*"
            ],
        ),
        aws.GetAmiFilterArgs(
            name="virtualization-type",
            values=["hvm"],
        ),
    ],
    owners=["099720109477"])

security_group = aws.ec2.SecurityGroup('ssh and node public access',
                                       description='Enable SSH + node access',
                                       egress=[
                                           {
                                               'protocol': '-1',
                                               'fromPort': 0,