Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(pulumi-bot) Synced file(s) with aq17/pulumi-yaml #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Pulumi;
using Aws = Pulumi.Aws;
using Eks = Pulumi.Eks;

class MyStack : Stack
{
public MyStack()
{
var vpcId = Output.Create(Aws.Ec2.GetVpc.InvokeAsync(new Aws.Ec2.GetVpcArgs
{
Default = true,
})).Apply(invoke => invoke.Id);
var subnetIds = Output.Create(Aws.Ec2.GetSubnetIds.InvokeAsync(new Aws.Ec2.GetSubnetIdsArgs
{
VpcId = vpcId,
})).Apply(invoke => invoke.Ids);
var cluster = new Eks.Cluster("cluster", new Eks.ClusterArgs
{
VpcId = vpcId,
SubnetIds = subnetIds,
InstanceType = "t2.medium",
DesiredCapacity = 2,
MinSize = 1,
MaxSize = 2,
});
this.Kubeconfig = cluster.Kubeconfig;
}

[Output("kubeconfig")]
public Output<string> Kubeconfig { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package main

import (
"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2"
"github.com/pulumi/pulumi-eks/sdk/go/eks"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
vpcId := ec2.LookupVpc(ctx, map[string]interface{}{
"default": true,
}, nil).Id
subnetIds := ec2.GetSubnetIds(ctx, map[string]interface{}{
"vpcId": vpcId,
}, nil).Ids
cluster, err := eks.NewCluster(ctx, "cluster", &eks.ClusterArgs{
VpcId: pulumi.String(vpcId),
SubnetIds: interface{}(subnetIds),
InstanceType: pulumi.String("t2.medium"),
DesiredCapacity: pulumi.Int(2),
MinSize: pulumi.Int(1),
MaxSize: pulumi.Int(2),
})
if err != nil {
return err
}
ctx.Export("kubeconfig", cluster.Kubeconfig)
return nil
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
vpcId = invoke("aws:ec2/getVpc:getVpc", {
default = true
}).id
subnetIds = invoke("aws:ec2/getSubnetIds:getSubnetIds", {
vpcId = vpcId
}).ids

resource cluster "eks:index:Cluster" {
__logicalName = "cluster"
vpcId = vpcId
subnetIds = subnetIds
instanceType = "t2.medium"
desiredCapacity = 2
minSize = 1
maxSize = 2
}

output kubeconfig {
__logicalName = "kubeconfig"
value = cluster.kubeconfig
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import pulumi
import pulumi_aws as aws
import pulumi_eks as eks

vpc_id = aws.ec2.get_vpc().id
subnet_ids = aws.ec2.get_subnet_ids().ids
cluster = eks.Cluster("cluster",
vpc_id=vpc_id,
subnet_ids=subnet_ids,
instance_type="t2.medium",
desired_capacity=2,
min_size=1,
max_size=2)
pulumi.export("kubeconfig", cluster.kubeconfig)
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
resource siteBucket "aws-native:s3:Bucket" {
__logicalName = "site-bucket"
websiteConfiguration = {
indexDocument = "index.html"
}
}

resource indexHtml "aws:s3/bucketObject:BucketObject" {
__logicalName = "index.html"
bucket = siteBucket.id
source = fileAsset("./www/index.html")
acl = "public-read"
contentType = "text/html"
}

resource faviconPng "aws:s3/bucketObject:BucketObject" {
__logicalName = "favicon.png"
bucket = siteBucket.id
source = fileAsset("./www/favicon.png")
acl = "public-read"
contentType = "image/png"
}

resource bucketPolicy "aws:s3/bucketPolicy:BucketPolicy" {
__logicalName = "bucketPolicy"
bucket = siteBucket.id
policy = "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Effect\": \"Allow\",\n \"Principal\": \"*\",\n \"Action\": [\"s3:GetObject\"],\n \"Resource\": [\"${siteBucket.arn}/*\"]\n }\n ]\n}\n"
}

output bucketName {
__logicalName = "bucketName"
value = siteBucket.bucketName
}

output websiteUrl {
__logicalName = "websiteUrl"
value = siteBucket.websiteURL
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import pulumi
import pulumi_aws as aws
import pulumi_aws_native as aws_native

site_bucket = aws_native.s3.Bucket("site-bucket", website_configuration=aws_native.s3.BucketWebsiteConfigurationArgs(
index_document="index.html",
))
index_html = aws.s3.BucketObject("index.html",
bucket=site_bucket.id,
source=pulumi.FileAsset("./www/index.html"),
acl="public-read",
content_type="text/html")
favicon_png = aws.s3.BucketObject("favicon.png",
bucket=site_bucket.id,
source=pulumi.FileAsset("./www/favicon.png"),
acl="public-read",
content_type="image/png")
bucket_policy = aws.s3.BucketPolicy("bucketPolicy",
bucket=site_bucket.id,
policy=site_bucket.arn.apply(lambda arn: f"""{{
"Version": "2012-10-17",
"Statement": [
{{
"Effect": "Allow",
"Principal": "*",
"Action": ["s3:GetObject"],
"Resource": ["{arn}/*"]
}}
]
}}
"""))
pulumi.export("bucketName", site_bucket.bucket_name)
pulumi.export("websiteUrl", site_bucket.website_url)
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Pulumi;
using Aws = Pulumi.Aws;
using Awsx = Pulumi.Awsx;

class MyStack : Stack
{
public MyStack()
{
var cluster = new Aws.Ecs.Cluster("cluster", new Aws.Ecs.ClusterArgs
{
});
var lb = new Awsx.Lb.ApplicationLoadBalancer("lb", new Awsx.Lb.ApplicationLoadBalancerArgs
{
});
var nginx = new Awsx.Ecs.FargateService("nginx", new Awsx.Ecs.FargateServiceArgs
{
Cluster = cluster.Arn,
TaskDefinitionArgs = new Awsx.Ecs.Inputs.FargateServiceTaskDefinitionArgs
{
Container = new Awsx.Ecs.Inputs.TaskDefinitionContainerDefinitionArgs
{
Image = "nginx:latest",
Cpu = 512,
Memory = 128,
PortMappings =
{
new Awsx.Ecs.Inputs.TaskDefinitionPortMappingArgs
{
ContainerPort = 80,
TargetGroup = lb.DefaultTargetGroup,
},
},
},
},
});
this.Url = lb.LoadBalancer.Apply(loadBalancer => loadBalancer.DnsName);
}

[Output("url")]
public Output<string> Url { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package main

import (
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ecs"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/lb"
"github.com/pulumi/pulumi-awsx/sdk/go/awsx/ecs"
"github.com/pulumi/pulumi-awsx/sdk/go/awsx/lb"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cluster, err := ecs.NewCluster(ctx, "cluster", nil)
if err != nil {
return err
}
lb, err := lb.NewApplicationLoadBalancer(ctx, "lb", nil)
if err != nil {
return err
}
_, err = ecs.NewFargateService(ctx, "nginx", &ecs.FargateServiceArgs{
Cluster: cluster.Arn,
TaskDefinitionArgs: &ecs.FargateServiceTaskDefinitionArgs{
Container: &ecs.TaskDefinitionContainerDefinitionArgs{
Image: pulumi.String("nginx:latest"),
Cpu: pulumi.Int(512),
Memory: pulumi.Int(128),
PortMappings: []ecs.TaskDefinitionPortMappingArgs{
&ecs.TaskDefinitionPortMappingArgs{
ContainerPort: pulumi.Int(80),
TargetGroup: lb.DefaultTargetGroup,
},
},
},
},
})
if err != nil {
return err
}
ctx.Export("url", lb.LoadBalancer.ApplyT(func(loadBalancer *lb.LoadBalancer) (string, error) {
return loadBalancer.DnsName, nil
}).(pulumi.StringOutput))
return nil
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";

const cluster = new aws.ecs.Cluster("cluster", {});
const lb = new awsx.lb.ApplicationLoadBalancer("lb", {});
const nginx = new awsx.ecs.FargateService("nginx", {
cluster: cluster.arn,
taskDefinitionArgs: {
container: {
image: "nginx:latest",
cpu: 512,
memory: 128,
portMappings: [{
containerPort: 80,
targetGroup: lb.defaultTargetGroup,
}],
},
},
});
export const url = lb.loadBalancer.dnsName;
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
resource cluster "aws:ecs/cluster:Cluster" {
__logicalName = "cluster"
}

resource lb "awsx:lb:ApplicationLoadBalancer" {
__logicalName = "lb"
}

resource nginx "awsx:ecs:FargateService" {
__logicalName = "nginx"
cluster = cluster.arn
taskDefinitionArgs = {
container = {
image = "nginx:latest",
cpu = 512,
memory = 128,
portMappings = [{
containerPort = 80,
targetGroup = lb.defaultTargetGroup
}]
}
}
}

output url {
__logicalName = "url"
value = lb.loadBalancer.dnsName
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pulumi
import pulumi_aws as aws
import pulumi_awsx as awsx

cluster = aws.ecs.Cluster("cluster")
lb = awsx.lb.ApplicationLoadBalancer("lb")
nginx = awsx.ecs.FargateService("nginx",
cluster=cluster.arn,
task_definition_args=awsx.ecs.FargateServiceTaskDefinitionArgs(
container=awsx.ecs.TaskDefinitionContainerDefinitionArgs(
image="nginx:latest",
cpu=512,
memory=128,
port_mappings=[awsx.ecs.TaskDefinitionPortMappingArgs(
container_port=80,
target_group=lb.default_target_group,
)],
),
))
pulumi.export("url", lb.load_balancer.dns_name)
Loading