Add an AWS Fargate example in Go
ADD
aws-go-fargate/.gitignore
+/vendor/
+aws-go-fargate

ADD
aws-go-fargate/Gopkg.lock
+# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
+
+
+[[projects]]
+ digest = "1:b6d886569181ec96ca83d529f4d6ba0cbf92ace7bb6f633f90c5f34d9bba7aab"
+ name = "github.com/blang/semver"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "ba2c2ddd89069b46a7011d4106f6868f17ee1705"
+ version = "v3.6.1"
+
+[[projects]]
+ digest = "1:6de9cdf8ab8dbedf93fc39e7ec35a41a9aa206488a922f8b0e4a31940c36b081"
+ name = "github.com/cheggaaa/pb"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "ca7ab10606663e9efdbc3c1ad157459b5a2b0edf"
+ version = "v3.0.4"
+
+[[projects]]
+ digest = "1:b7b063b8125b7aeaf179aa4564ba60c896551d702f7c824ace98cc654fc813a0"
+ name = "github.com/djherbis/times"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "847c5208d8924cea0acea3376ff62aede93afe39"
+ version = "v1.2.0"
+
+[[projects]]
+ digest = "1:b498b36dbb2b306d1c5205ee5236c9e60352be8f9eea9bf08186723a9f75b4f3"
+ name = "github.com/emirpasic/gods"
+ packages = [
+ "containers",
+ "lists",
+ "lists/arraylist",
+ "trees",
+ "trees/binaryheap",
+ "utils",
+ ]
+ pruneopts = "UT"
+ revision = "1615341f118ae12f353cc8a983f35b584342c9b3"
+ version = "v1.12.0"
+
+[[projects]]
+ digest = "1:d7b2d6ad2a9768bb5c9e3bfa4d9ceaa635ca2737cca288507986f116fa4b8da2"
+ name = "github.com/gofrs/flock"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "392e7fae8f1b0bdbd67dad7237d23f618feb6dbb"
+ version = "v0.7.1"
+
+[[projects]]
+ digest = "1:ad731b12118c31740b53aa00030c7c9a635b6c5121a3d0484dc3bf6dda989988"
+ name = "github.com/gogo/protobuf"
+ packages = [
+ "io",
+ "proto",
+ ]
+ pruneopts = "UT"
+ revision = "5628607bb4c51c3157aacc3a50f0ab707582b805"
+ version = "v1.3.1"
+
+[[projects]]
+ branch = "master"
+ digest = "1:1ba1d79f2810270045c328ae5d674321db34e3aae468eb4233883b473c5c0467"
+ name = "github.com/golang/glog"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "23def4e6c14b4da8ac2ed8007337bc5eb5007998"
+
+[[projects]]
+ digest = "1:f762e71500c189feab20aadc5ed008780906682685d553b3e54f7ad3c98489dc"
+ name = "github.com/golang/protobuf"
+ packages = [
+ "proto",
+ "protoc-gen-go/descriptor",
+ "ptypes",
+ "ptypes/any",
+ "ptypes/duration",
+ "ptypes/empty",
+ "ptypes/struct",
+ "ptypes/timestamp",
+ ]
+ pruneopts = "UT"
+ revision = "d23c5127dc24889085f8ccea5c9d560a57a879d8"
+ version = "v1.3.3"
+
+[[projects]]
+ branch = "master"
+ digest = "1:1a1206efd03a54d336dce7bb8719e74f2f8932f661cb9f57d5813a1d99c083d8"
+ name = "github.com/grpc-ecosystem/grpc-opentracing"
+ packages = ["go/otgrpc"]
+ pruneopts = "UT"
+ revision = "8e809c8a86450a29b90dcc9efbf062d0fe6d9746"
+
+[[projects]]
+ digest = "1:0ade334594e69404d80d9d323445d2297ff8161637f9b2d347cc6973d2d6f05b"
+ name = "github.com/hashicorp/errwrap"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "8a6fb523712970c966eefc6b39ed2c5e74880354"
+ version = "v1.0.0"
+
+[[projects]]
+ digest = "1:f668349b83f7d779567c880550534addeca7ebadfdcf44b0b9c39be61864b4b7"
+ name = "github.com/hashicorp/go-multierror"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "886a7fbe3eb1c874d46f623bfa70af45f425b3d1"
+ version = "v1.0.0"
+
+[[projects]]
+ digest = "1:870d441fe217b8e689d7949fef6e43efbc787e50f200cb1e70dbca9204a1d6be"
+ name = "github.com/inconshreveable/mousetrap"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75"
+ version = "v1.0"
+
+[[projects]]
+ branch = "master"
+ digest = "1:62fe3a7ea2050ecbd753a71889026f83d73329337ada66325cbafd5dea5f713d"
+ name = "github.com/jbenet/go-context"
+ packages = ["io"]
+ pruneopts = "UT"
+ revision = "d14ea06fba99483203c19d92cfcd13ebe73135f4"
+
+[[projects]]
+ digest = "1:fd7f169f32c221b096c74e756bda16fe22d3bb448bbf74042fd0700407a1f92f"
+ name = "github.com/kevinburke/ssh_config"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "6cfae18c12b8934b1afba3ce8159476fdef666ba"
+ version = "1.0"
+
+[[projects]]
+ digest = "1:eb1bffab7260bf5ddc95fc2c41d4bfee1a4f5fe18194b3946fe8a9e9121a282f"
+ name = "github.com/mattn/go-runewidth"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "a4df4ddbff020e131056d91f580a1cdcd806e3ae"
+ version = "v0.0.8"
+
+[[projects]]
+ digest = "1:5d231480e1c64a726869bc4142d270184c419749d34f167646baa21008eb0a79"
+ name = "github.com/mitchellh/go-homedir"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "af06845cf3004701891bf4fdb884bfe4920b3727"
+ version = "v1.1.0"
+
+[[projects]]
+ digest = "1:69530a15507094162be4eb3180c1d68b787177e8c9bbe76d4da40d44d6586f6f"
+ name = "github.com/mitchellh/go-ps"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "147ff83818ae939913b2e20b91ae3cd6c391771c"
+ version = "v1.0.0"
+
+[[projects]]
+ digest = "1:d07bd28263c09c5d7f6502e8ddac63e027eca0eafcd07632790d958b50360317"
+ name = "github.com/opentracing/basictracer-go"
+ packages = [
+ ".",
+ "wire",
+ ]
+ pruneopts = "UT"
+ revision = "1b32af207119a14b1b231d451df3ed04a72efebf"
+ version = "v1.0.0"
+
+[[projects]]
+ digest = "1:11e62d6050198055e6cd87ed57e5d8c669e84f839c16e16f192374d913d1a70d"
+ name = "github.com/opentracing/opentracing-go"
+ packages = [
+ ".",
+ "ext",
+ "log",
+ ]
+ pruneopts = "UT"
+ revision = "659c90643e714681897ec2521c60567dd21da733"
+ version = "v1.1.0"
+
+[[projects]]
+ digest = "1:9e1d37b58d17113ec3cb5608ac0382313c5b59470b94ed97d0976e69c7022314"
+ name = "github.com/pkg/errors"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "614d223910a179a466c1767a985424175c39b465"
+ version = "v0.9.1"
+
+[[projects]]
+ digest = "1:f138a8315f154ca19ff069a093f25ae1d370bb3418062c83b6f6887943c66287"
+ name = "github.com/pulumi/pulumi"
+ packages = [
+ "pkg/apitype",
+ "pkg/diag",
+ "pkg/diag/colors",
+ "pkg/encoding",
+ "pkg/resource",
+ "pkg/resource/config",
+ "pkg/resource/plugin",
+ "pkg/tokens",
+ "pkg/util/archive",
+ "pkg/util/ciutil",
+ "pkg/util/cmdutil",
+ "pkg/util/contract",
+ "pkg/util/fsutil",
+ "pkg/util/gitutil",
+ "pkg/util/httputil",
+ "pkg/util/logging",
+ "pkg/util/mapper",
+ "pkg/util/result",
+ "pkg/util/retry",
+ "pkg/util/rpcutil",
+ "pkg/util/rpcutil/rpcerror",
+ "pkg/version",
+ "pkg/workspace",
+ "sdk/go/pulumi",
+ "sdk/proto/go",
+ ]
+ pruneopts = "UT"
+ revision = "d6bafd5b4b68a0797b7857c57a58419d6ba55fc4"
+ version = "v1.9.1"
+
+[[projects]]
+ branch = "tfgo"
+ digest = "1:dafebe3cec79989a21a0773c356887475966aa74b0e2fe3948a4c7e2a55f2160"
+ name = "github.com/pulumi/pulumi-aws"
+ packages = [
+ "sdk/go/aws/ec2",
+ "sdk/go/aws/ecs",
+ "sdk/go/aws/elasticloadbalancingv2",
+ "sdk/go/aws/iam",
+ ]
+ pruneopts = "UT"
+ revision = "26eb820d04193a8f6e8b9ccb37b41f1ec6787c98"
+
+[[projects]]
+ digest = "1:d0d418e1c02e6fc00259ef09d0d4f5135fc6aedac356ff0a11f4e5ef0c447270"
+ name = "github.com/sergi/go-diff"
+ packages = ["diffmatchpatch"]
+ pruneopts = "UT"
+ revision = "58c5cb1602ee9676b5d3590d782bedde80706fcc"
+ version = "v1.1.0"
+
+[[projects]]
+ digest = "1:e096613fb7cf34743d49af87d197663cfccd61876e2219853005a57baedfa562"
+ name = "github.com/spf13/cobra"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "f2b07da1e2c38d5f12845a4f607e2e1018cbb1f5"
+ version = "v0.0.5"
+
+[[projects]]
+ digest = "1:524b71991fc7d9246cc7dc2d9e0886ccb97648091c63e30eef619e6862c955dd"
+ name = "github.com/spf13/pflag"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "2e9d26c8c37aae03e3f9d4e90b7116f5accb7cab"
+ version = "v1.0.5"
+
+[[projects]]
+ digest = "1:e4ed0afd67bf7be353921665cdac50834c867ff1bba153efc0745b755a7f5905"
+ name = "github.com/src-d/gcfg"
+ packages = [
+ ".",
+ "scanner",
+ "token",
+ "types",
+ ]
+ pruneopts = "UT"
+ revision = "1ac3a1ac202429a54835fe8408a92880156b489d"
+ version = "v1.4.0"
+
+[[projects]]
+ branch = "master"
+ digest = "1:061958e35bd814b8105aa85d96d23cd99108843465f07e7bdf337f3efacb6dad"
+ name = "github.com/texttheater/golang-levenshtein"
+ packages = ["levenshtein"]
+ pruneopts = "UT"
+ revision = "eb6844b05fc6f7e10932b0621c7f5f7e8890541d"
+
+[[projects]]
+ digest = "1:41e3f222b0852a3c9cf1cce8cfc5e52c0084a6309e5a486a2ce4e075125271c8"
+ name = "github.com/uber/jaeger-client-go"
+ packages = [
+ ".",
+ "internal/baggage",
+ "internal/reporterstats",
+ "internal/spanlog",
+ "internal/throttler",
+ "log",
+ "thrift",
+ "thrift-gen/agent",
+ "thrift-gen/jaeger",
+ "thrift-gen/sampling",
+ "thrift-gen/zipkincore",
+ "transport/zipkin",
+ "utils",
+ ]
+ pruneopts = "UT"
+ revision = "2d55657eac169e2a86b4fcc1a421e26a9a485b63"
+ version = "v2.22.1"
+
+[[projects]]
+ digest = "1:d7b6fd08442b8d26882fae2c859a0d63962d72a533476a217d46743ed30cb803"
+ name = "github.com/uber/jaeger-lib"
+ packages = ["metrics"]
+ pruneopts = "UT"
+ revision = "a87ae9d84fb038a8d79266298970720be7c80fcd"
+ version = "v2.2.0"
+
+[[projects]]
+ digest = "1:172f94a6b3644a8f9e6b5e5b7fc9fe1e42d424f52a0300b2e7ab1e57db73f85d"
+ name = "github.com/xanzy/ssh-agent"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "6a3e2ff9e7c564f36873c2e36413f634534f1c44"
+ version = "v0.2.1"
+
+[[projects]]
+ digest = "1:c708d00d1097e62bf4f3a72f239efa7dafc257581421b0b7d3789e1ff5299f30"
+ name = "go.uber.org/atomic"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "40ae6a40a970ef4cdbffa7b24b280e316db8accc"
+ version = "v1.5.1"
+
+[[projects]]
+ branch = "master"
+ digest = "1:732167930ca9f3b389a1011da8fb4921bc49dabdd6e4932e84c6229be3114ead"
+ name = "golang.org/x/crypto"
+ packages = [
+ "blowfish",
+ "cast5",
+ "chacha20",
+ "curve25519",
+ "ed25519",
+ "ed25519/internal/edwards25519",
+ "internal/subtle",
+ "openpgp",
+ "openpgp/armor",
+ "openpgp/elgamal",
+ "openpgp/errors",
+ "openpgp/packet",
+ "openpgp/s2k",
+ "pbkdf2",
+ "poly1305",
+ "ssh",
+ "ssh/agent",
+ "ssh/internal/bcrypt_pbkdf",
+ "ssh/knownhosts",
+ "ssh/terminal",
+ ]
+ pruneopts = "UT"
+ revision = "c9f3fb736b729628ec1e9c1a6b4313e883f452f9"
+
+[[projects]]
+ branch = "master"
+ digest = "1:802fc3c45ff4507b6e4a5c0c5ea55836242aeac3b8eddfe31d5d80a3cac50731"
+ name = "golang.org/x/lint"
+ packages = [
+ ".",
+ "golint",
+ ]
+ pruneopts = "UT"
+ revision = "910be7a94367618fd0fd25eaabbee4fdc0ac7092"
+
+[[projects]]
+ branch = "master"
+ digest = "1:5f4febb068e1910d3790fd682d564a85ea0773f1a45072fd723170c78034f2b5"
+ name = "golang.org/x/net"
+ packages = [
+ "context",
+ "http/httpguts",
+ "http2",
+ "http2/hpack",
+ "idna",
+ "internal/socks",
+ "internal/timeseries",
+ "proxy",
+ "trace",
+ ]
+ pruneopts = "UT"
+ revision = "16171245cfb220d5317888b716d69c1fb4e7992b"
+
+[[projects]]
+ branch = "master"
+ digest = "1:df247358f60bffa5c6968a0f40edda9293c11572b664dd2c1550ff2c989a953a"
+ name = "golang.org/x/sys"
+ packages = [
+ "cpu",
+ "unix",
+ "windows",
+ "windows/registry",
+ ]
+ pruneopts = "UT"
+ revision = "d101bd2416d505c0448a6ce8a282482678040a89"
+
+[[projects]]
+ digest = "1:8d8faad6b12a3a4c819a3f9618cb6ee1fa1cfc33253abeeea8b55336721e3405"
+ name = "golang.org/x/text"
+ packages = [
+ "collate",
+ "collate/build",
+ "internal/colltab",
+ "internal/gen",
+ "internal/language",
+ "internal/language/compact",
+ "internal/tag",
+ "internal/triegen",
+ "internal/ucd",
+ "language",
+ "secure/bidirule",
+ "transform",
+ "unicode/bidi",
+ "unicode/cldr",
+ "unicode/norm",
+ "unicode/rangetable",
+ ]
+ pruneopts = "UT"
+ revision = "342b2e1fbaa52c93f31447ad2c6abc048c63e475"
+ version = "v0.3.2"
+
+[[projects]]
+ branch = "master"
+ digest = "1:1050c11c1d756701b8a247428e7af6cdc4f45b5bca163ae8b9c78ea0e2455e87"
+ name = "golang.org/x/tools"
+ packages = [
+ "go/ast/astutil",
+ "go/gcexportdata",
+ "go/internal/gcimporter",
+ "go/types/typeutil",
+ ]
+ pruneopts = "UT"
+ revision = "67a4523381ef904fe70f6cc4b54cf1baad90d21a"
+
+[[projects]]
+ branch = "master"
+ digest = "1:0c679e19d1865dd65e7ec400bf9562d8f161cf59c4f74c0bb50f365fc9fb19eb"
+ name = "google.golang.org/genproto"
+ packages = ["googleapis/rpc/status"]
+ pruneopts = "UT"
+ revision = "fb4a7afc5178aa5e833097749ea70324e81e7f80"
+
+[[projects]]
+ digest = "1:34cd41d4f3fdd728e57e21cd382f6c4fa1b0bafb6a91b50feefa16c23b5e548b"
+ name = "google.golang.org/grpc"
+ packages = [
+ ".",
+ "attributes",
+ "backoff",
+ "balancer",
+ "balancer/base",
+ "balancer/roundrobin",
+ "binarylog/grpc_binarylog_v1",
+ "codes",
+ "connectivity",
+ "credentials",
+ "credentials/internal",
+ "encoding",
+ "encoding/proto",
+ "grpclog",
+ "internal",
+ "internal/backoff",
+ "internal/balancerload",
+ "internal/binarylog",
+ "internal/buffer",
+ "internal/channelz",
+ "internal/envconfig",
+ "internal/grpcrand",
+ "internal/grpcsync",
+ "internal/resolver/dns",
+ "internal/resolver/passthrough",
+ "internal/syscall",
+ "internal/transport",
+ "keepalive",
+ "metadata",
+ "naming",
+ "peer",
+ "reflection",
+ "reflection/grpc_reflection_v1alpha",
+ "resolver",
+ "serviceconfig",
+ "stats",
+ "status",
+ "tap",
+ ]
+ pruneopts = "UT"
+ revision = "a89bee78ddf0f67f27c06b1b2b1b071c18408724"
+ version = "v1.27.0"
+
+[[projects]]
+ digest = "1:eb27cfcaf8d7e4155224dd0a209f1d0ab19784fef01be142638b78b7b6becd6b"
+ name = "gopkg.in/src-d/go-billy.v4"
+ packages = [
+ ".",
+ "helper/chroot",
+ "helper/polyfill",
+ "osfs",
+ "util",
+ ]
+ pruneopts = "UT"
+ revision = "780403cfc1bc95ff4d07e7b26db40a6186c5326e"
+ version = "v4.3.2"
+
+[[projects]]
+ digest = "1:b2ad0a18676cd4d5b4b180709c1ea34dbabd74b3d7db0cc01e6d287d5f1e3a99"
+ name = "gopkg.in/src-d/go-git.v4"
+ packages = [
+ ".",
+ "config",
+ "internal/revision",
+ "internal/url",
+ "plumbing",
+ "plumbing/cache",
+ "plumbing/filemode",
+ "plumbing/format/config",
+ "plumbing/format/diff",
+ "plumbing/format/gitignore",
+ "plumbing/format/idxfile",
+ "plumbing/format/index",
+ "plumbing/format/objfile",
+ "plumbing/format/packfile",
+ "plumbing/format/pktline",
+ "plumbing/object",
+ "plumbing/protocol/packp",
+ "plumbing/protocol/packp/capability",
+ "plumbing/protocol/packp/sideband",
+ "plumbing/revlist",
+ "plumbing/storer",
+ "plumbing/transport",
+ "plumbing/transport/client",
+ "plumbing/transport/file",
+ "plumbing/transport/git",
+ "plumbing/transport/http",
+ "plumbing/transport/internal/common",
+ "plumbing/transport/server",
+ "plumbing/transport/ssh",
+ "storage",
+ "storage/filesystem",
+ "storage/filesystem/dotgit",
+ "storage/memory",
+ "utils/binary",
+ "utils/diff",
+ "utils/ioutil",
+ "utils/merkletrie",
+ "utils/merkletrie/filesystem",
+ "utils/merkletrie/index",
+ "utils/merkletrie/internal/frame",
+ "utils/merkletrie/noder",
+ ]
+ pruneopts = "UT"
+ revision = "0d1a009cbb604db18be960db5f1525b99a55d727"
+ version = "v4.13.1"
+
+[[projects]]
+ digest = "1:78d374b493e747afa9fbb2119687e3740a7fb8d0ebabddfef0a012593aaecbb3"
+ name = "gopkg.in/warnings.v0"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "ec4a0fea49c7b46c2aeb0b51aac55779c607e52b"
+ version = "v0.1.2"
+
+[[projects]]
+ digest = "1:55b110c99c5fdc4f14930747326acce56b52cfce60b24b1c03ef686ac0e46bb1"
+ name = "gopkg.in/yaml.v2"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "53403b58ad1b561927d19068c655246f2db79d48"
+ version = "v2.2.8"
+
+[[projects]]
+ branch = "master"
+ digest = "1:0e1b7edf7f2aadeb2943e42c7b9cb2de97711d2aae6767e89ef5d64d45ba8b48"
+ name = "sourcegraph.com/sourcegraph/appdash"
+ packages = [
+ ".",
+ "internal/wire",
+ "opentracing",
+ ]
+ pruneopts = "UT"
+ revision = "ebfcffb1b5c00031ce797183546746715a3cfe87"
+
+[solve-meta]
+ analyzer-name = "dep"
+ analyzer-version = 1
+ input-imports = [
+ "github.com/pulumi/pulumi-aws/sdk/go/aws/ec2",
+ "github.com/pulumi/pulumi-aws/sdk/go/aws/ecs",
+ "github.com/pulumi/pulumi-aws/sdk/go/aws/elasticloadbalancingv2",
+ "github.com/pulumi/pulumi-aws/sdk/go/aws/iam",
+ "github.com/pulumi/pulumi/sdk/go/pulumi",
+ ]
+ solver-name = "gps-cdcl"
+ solver-version = 1

ADD
aws-go-fargate/Gopkg.toml
+# Gopkg.toml example
+#
+# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
+# for detailed Gopkg.toml documentation.
+#
+# required = ["github.com/user/thing/cmd/thing"]
+# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
+#
+# [[constraint]]
+# name = "github.com/user/project"
+# version = "1.0.0"
+#
+# [[constraint]]
+# name = "github.com/user/project2"
+# branch = "dev"
+# source = "github.com/myfork/project2"
+#
+# [[override]]
+# name = "github.com/x/y"
+# version = "2.4.0"
+#
+# [prune]
+# non-go = false
+# go-tests = true
+# unused-packages = true
+
+
+[[constraint]]
+ name = "github.com/pulumi/pulumi"
+ version = "1.9.1"
+
+[[constraint]]
+ name = "github.com/pulumi/pulumi-aws"
+ branch = "tfgo"
+
+[prune]
+ go-tests = true
+ unused-packages = true

ADD
aws-go-fargate/Pulumi.yaml
+name: aws-go-fargate
+runtime: go
+description: An end-to-end AWS ECS Fargate infrastructure as code project.

ADD
aws-go-fargate/main.go
+package main
+
+import (
+ "github.com/pulumi/pulumi-aws/sdk/go/aws/ec2"
+ "github.com/pulumi/pulumi-aws/sdk/go/aws/ecs"
+ elb "github.com/pulumi/pulumi-aws/sdk/go/aws/elasticloadbalancingv2"
+ "github.com/pulumi/pulumi-aws/sdk/go/aws/iam"
+ "github.com/pulumi/pulumi/sdk/go/pulumi"
+)
+
+func main() {
+ pulumi.Run(func(ctx *pulumi.Context) error {
+ // Read back the default VPC and public subnets, which we will use.
+ t := true
+ vpc, err := ec2.LookupVpc(ctx, &ec2.LookupVpcArgs{Default: &t})
+ if err != nil {
+ return err
+ }
+ subnet, err := ec2.GetSubnetIds(ctx, &ec2.GetSubnetIdsArgs{VpcId: vpc.Id})
+ if err != nil {
+ return err
+ }
+
+ // Create a SecurityGroup that permits HTTP ingress and unrestricted egress.
+ webSg, err := ec2.NewSecurityGroup(ctx, "web-sg", &ec2.SecurityGroupArgs{
+ VpcId: pulumi.String(vpc.Id),
+ Egress: ec2.SecurityGroupEgressArray{
+ ec2.SecurityGroupEgressArgs{
+ Protocol: pulumi.String("-1"),
+ FromPort: pulumi.Int(0),
+ ToPort: pulumi.Int(0),
+ CidrBlocks: pulumi.StringArray{pulumi.String("0.0.0.0/0")},
+ },
+ },
+ Ingress: ec2.SecurityGroupIngressArray{
+ ec2.SecurityGroupIngressArgs{
+ Protocol: pulumi.String("tcp"),
+ FromPort: pulumi.Int(80),
+ ToPort: pulumi.Int(80),
+ CidrBlocks: pulumi.StringArray{pulumi.String("0.0.0.0/0")},
+ },
+ },
+ })
+ if err != nil {
+ return err
+ }
+
+ // Create an ECS cluster to run a container-based service.
+ cluster, err := ecs.NewCluster(ctx, "app-cluster", nil)
+ if err != nil {
+ return err
+ }
+
+ // Create an IAM role that can be used by our service's task.
+ taskExecRole, err := iam.NewRole(ctx, "task-exec-role", &iam.RoleArgs{
+ AssumeRolePolicy: pulumi.String(`{
+ "Version": "2008-10-17",
+ "Statement": [{
+ "Sid": "",
+ "Effect": "Allow",
+ "Principal": {
+ "Service": "ecs-tasks.amazonaws.com"
+ },
+ "Action": "sts:AssumeRole"
+ }]
+}`),
+ })
+ if err != nil {
+ return err
+ }
+ _, err = iam.NewRolePolicyAttachment(ctx, "task-exec-policy", &iam.RolePolicyAttachmentArgs{
+ Role: taskExecRole.Name,
+ PolicyArn: pulumi.String("arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"),
+ })
+ if err != nil {
+ return err
+ }
+
+ // Create a load balancer to listen for HTTP traffic on port 80.
+ webLb, err := elb.NewLoadBalancer(ctx, "web-lb", &elb.LoadBalancerArgs{
+ Subnets: toPulumiStringArray(subnet.Ids),
+ SecurityGroups: pulumi.StringArray{webSg.ID().ToStringOutput()},
+ })
+ if err != nil {
+ return err
+ }
+ webTg, err := elb.NewTargetGroup(ctx, "web-tg", &elb.TargetGroupArgs{
+ Port: pulumi.Int(80),
+ Protocol: pulumi.String("HTTP"),
+ TargetType: pulumi.String("ip"),
+ VpcId: pulumi.String(vpc.Id),
+ })
+ if err != nil {
+ return err
+ }
+ webListener, err := elb.NewListener(ctx, "web-listener", &elb.ListenerArgs{
+ LoadBalancerArn: webLb.Arn,
+ Port: pulumi.Int(80),
+ DefaultActions: elb.ListenerDefaultActionArray{
+ elb.ListenerDefaultActionArgs{
+ Type: pulumi.String("forward"),
+ TargetGroupArn: webTg.Arn,
+ },
+ },
+ })
+ if err != nil {
+ return err
+ }
+
+ // Spin up a load balanced service running NGINX.
+ appTask, err := ecs.NewTaskDefinition(ctx, "app-task", &ecs.TaskDefinitionArgs{
+ Family: pulumi.String("fargate-task-definition"),
+ Cpu: pulumi.String("256"),
+ Memory: pulumi.String("512"),
+ NetworkMode: pulumi.String("awsvpc"),
+ RequiresCompatibilities: pulumi.StringArray{pulumi.String("FARGATE")},
+ ExecutionRoleArn: taskExecRole.Arn,
+ ContainerDefinitions: pulumi.String(`[{
+ "name": "my-app",
+ "image": "nginx",
+ "portMappings": [{
+ "containerPort": 80,
+ "hostPort": 80,
+ "protocol": "tcp"
+ }]
+}]`),
+ })
+ if err != nil {
+ return err
+ }
+ _, err = ecs.NewService(ctx, "app-svc", &ecs.ServiceArgs{
+ Cluster: cluster.Arn,
+ DesiredCount: pulumi.Int(5),
+ LaunchType: pulumi.String("FARGATE"),
+ TaskDefinition: appTask.Arn,
+ NetworkConfiguration: &ecs.ServiceNetworkConfigurationArgs{
+ AssignPublicIp: pulumi.Bool(true),
+ Subnets: toPulumiStringArray(subnet.Ids),
+ SecurityGroups: pulumi.StringArray{webSg.ID().ToStringOutput()},
+ },
+ LoadBalancers: ecs.ServiceLoadBalancerArray{
+ ecs.ServiceLoadBalancerArgs{
+ TargetGroupArn: webTg.Arn,
+ ContainerName: pulumi.String("my-app"),
+ ContainerPort: pulumi.Int(80),
+ },
+ },
+ }, pulumi.DependsOn([]pulumi.Resource{webListener}))
+
+ // Export the resulting web address.
+ ctx.Export("url", webLb.DnsName)
+ return nil
+ })
+}
+
+func toPulumiStringArray(a []string) pulumi.StringArrayInput {
+ var res []pulumi.StringInput
+ for _, s := range a {
+ res = append(res, pulumi.String(s))
+ }
+ return pulumi.StringArray(res)
+}

Add an AWS Fargate example in Go (#540)