diff --git a/.github/workflows/scheduled-examples.yml b/.github/workflows/scheduled-examples.yml new file mode 100644 index 00000000000..7898b2dc56f --- /dev/null +++ b/.github/workflows/scheduled-examples.yml @@ -0,0 +1,77 @@ +name: Run tests +on: + schedule: + - cron: "0 8 * * *" + pull_request: + branches: + - main + workflow_dispatch: {} + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PULUMI_TEST_OWNER: "moolumi" + PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }} + AWS_REGION: "us-west-2" + PULUMI_API: https://api.pulumi-staging.io + +jobs: + test: + runs-on: ${{ matrix.platform }} + strategy: + matrix: + platform: + - ubuntu-latest + go-version: + - 1.18.x + node-version: + - 16.x + python-version: + - 3.7 + dotnet: + - 6.0.x + + steps: + - name: Install Java + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 11 + + - name: Install DotNet + uses: actions/setup-dotnet@v3 + with: + dotnet-version: ${{ matrix.dotnet }} + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Install Go + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go-version }} + + - name: Install Pulumi + uses: pulumi/actions@v4 + + - name: Install Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Check out the code + uses: actions/checkout@v3 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-region: ${{ env.AWS_REGION }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + role-duration-seconds: 14400 # 4 hours + role-session-name: pulumi-hugo-examples@githubActions + role-to-assume: ${{ secrets.AWS_CI_ROLE_ARN }} + + - name: Run the tests + run: make test-examples diff --git a/.prettierignore b/.prettierignore index 5e39abbb810..b7a1ffde2b9 100644 --- a/.prettierignore +++ b/.prettierignore @@ -15,3 +15,4 @@ yarn-error.log themes/default/theme themes/default/assets themes/default/layouts +themes/default/static/examples diff --git a/Makefile b/Makefile index e53065a3a59..9f9665212e3 100644 --- a/Makefile +++ b/Makefile @@ -79,3 +79,6 @@ new-learn-topic: .PHONY: new-template new-template: ./scripts/content/new-template.sh + +test-examples: + ./scripts/test-examples.sh preview diff --git a/scripts/test-examples.sh b/scripts/test-examples.sh new file mode 100755 index 00000000000..c822e627e59 --- /dev/null +++ b/scripts/test-examples.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +set -euo pipefail + +pulumi whoami -v + +# Delete build/test artifacts. +git clean -fdX themes/default/static/examples + +pushd themes/default/static/examples + for dir in */; do + project="$(basename $dir)" + + + echo "***" + echo "* $project" + echo "***" + + org="$(pulumi whoami -v --json | jq -r .user)" + stack="dev" + fqsn="${org}/${project}/${stack}" + + # Install dependencies. + pulumi -C "$project" install + + # Skip certain programs known not to work. + + # Java examples of FargateService erroneously complain about missing container declarations. + # https://github.com/pulumi/pulumi-awsx/issues/820 + if [[ "$project" == "awsx-vpc-fargate-service-java" ]]; then + continue + elif [[ "$project" == "load-balanced-fargate-ecr-java" ]]; then + continue + elif [[ "$project" == "load-balanced-fargate-nginx-java" ]]; then + continue + fi + + # Destroy any existing stacks. + pulumi -C "$project" cancel --stack $fqsn --yes || true + pulumi -C "$project" destroy --stack $fqsn --yes --refresh --remove || true + + # Delete any existing Docker images. + # docker rmi -f "$(docker images -aq)" || true + + # Create a new stack. + pulumi -C "$project" stack select $fqsn || pulumi -C "$project" stack init $fqsn + pulumi -C "$project" config set aws:region us-west-2 || true + + # Preview or deploy. + if [[ "$1" == "update" ]]; then + pulumi -C "$project" up --yes + else + pulumi -C "$project" preview + fi + + # Destroy and remove. + pulumi -C "$project" destroy --yes --remove + + done +popd + +# Delete build/test artifacts. +git clean -fdX themes/default/static/examples diff --git a/themes/default/content/docs/clouds/aws/guides/ecr.md b/themes/default/content/docs/clouds/aws/guides/ecr.md index 6e18e0e7209..0f4c3c9568d 100644 --- a/themes/default/content/docs/clouds/aws/guides/ecr.md +++ b/themes/default/content/docs/clouds/aws/guides/ecr.md @@ -92,6 +92,7 @@ func main() { if err != nil { return err } + ctx.Export("url", repository.Url) return nil }) @@ -261,193 +262,7 @@ entirely from code. This lets you version and deploy container changes easily al In the following example, creating an `Image` resource will build an image from the "./app" directory (relative to our project and containing Dockerfile), and publish it to our ECR repository provisioned above. -{{< chooser language "javascript,typescript,python,go,csharp,java,yaml" / >}} - -{{% choosable language javascript %}} - -```javascript -"use strict"; -const pulumi = require("@pulumi/pulumi"); -const awsx = require("@pulumi/awsx"); - -const repository = new awsx.ecr.Repository("repository"); - -const image = new awsx.ecr.Image("image", { - repositoryUrl: repository.url, - context: "./app", - platform: "linux/amd64", -}); - -exports.url = repository.url; -``` - -{{% /choosable %}} - -{{% choosable language typescript %}} - -```typescript -import * as pulumi from "@pulumi/pulumi"; -import * as awsx from "@pulumi/awsx"; - -const repository = new awsx.ecr.Repository("repository", { - forceDelete: true, -}); - -const image = new awsx.ecr.Image("image", { - repositoryUrl: repository.url, - context: "./app", - platform: "linux/amd64", -}); -``` - -{{% /choosable %}} - -{{% choosable language python %}} - -```python -import pulumi -import pulumi_awsx as awsx - -repository = awsx.ecr.Repository("repository", awsx.ecr.RepositoryArgs( - force_delete=True, -)) - -image = awsx.ecr.Image("image", awsx.ecr.ImageArgs( - repository_url=repository.url, - context="./app", - platform="linux/amd64", -)) - -pulumi.export("url", repository.url) -``` - -{{% /choosable %}} - -{{% choosable language go %}} - -```go -package main - -import ( - "github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/ecr" - "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -) - -func main() { - pulumi.Run(func(ctx *pulumi.Context) error { - repository, err := ecr.NewRepository(ctx, "repository", &ecr.RepositoryArgs{ - ForceDelete: pulumi.Bool(true), - }) - if err != nil { - return err - } - - _, err = ecr.NewImage(ctx, "image", &ecr.ImageArgs{ - RepositoryUrl: repository.Url, - Context: pulumi.String("./app"), - Platform: pulumi.String("linux/amd64"), - }) - if err != nil { - return err - } - - ctx.Export("url", repository.Url) - return nil - }) -} -``` - -{{% /choosable %}} - -{{% choosable language csharp %}} - -```csharp -using System.Collections.Generic; -using Pulumi; -using Awsx = Pulumi.Awsx; - -return await Deployment.RunAsync(() => -{ - var repository = new Awsx.Ecr.Repository("repository", new() - { - ForceDelete = true, - }); - - var image = new Awsx.Ecr.Image("image", new() - { - RepositoryUrl = repository.Url, - Context = "./app", - Platform = "linux/amd64", - }); - - return new Dictionary - { - ["url"] = repository.Url, - }; -}); -``` - -{{% /choosable %}} - -{{% choosable language java %}} - -```java -package myproject; - -import com.pulumi.Context; -import com.pulumi.Pulumi; -import com.pulumi.awsx.ecr.Repository; -import com.pulumi.awsx.ecr.RepositoryArgs; -import com.pulumi.awsx.ecr.Image; -import com.pulumi.awsx.ecr.ImageArgs; - -public class App { - public static void main(String[] args) { - Pulumi.run(App::stack); - } - - public static void stack(Context ctx) { - var repository = new Repository("repository", RepositoryArgs.builder() - .forceDelete(true) - .build()); - - var image = new Image("image", ImageArgs.builder() - .repositoryUrl(repository.url()) - .context("./app") - .platform("linux/amd64") - .build()); - - ctx.export("url", repository.url()); - } -} -``` - -{{% /choosable %}} - -{{% choosable language yaml %}} - -```yaml -name: my-project -runtime: yaml - -resources: - repository: - type: awsx:ecr:Repository - properties: - forceDelete: true - -image: - type: awsx:ecr:Image - properties: - repositoryUrl: ${repository.url} - context: "./app" - platform: "linux/amd64" - -outputs: - url: ${repository.url} -``` - -{{% /choosable %}} +{{< example path="awsx-ecr-image" languages="javascript,typescript,python,go,csharp,java,yaml" >}} As we run `pulumi up`, we will see Docker build output in the Pulumi CLI display. If there is an error, it'll be printed in the diagnostics section, but otherwise the resulting image name is printed: @@ -496,392 +311,7 @@ defaults to `latest`). The container instances require IAM permissions which are To use your private repository from an ECS task definition, reference it like so: -{{< chooser language "javascript,typescript,python,go,csharp,java,yaml" / >}} - -{{% choosable language "javascript" %}} - -```javascript -"use strict"; -const pulumi = require("@pulumi/pulumi"); -const aws = require("@pulumi/aws"); -const awsx = require("@pulumi/awsx"); - -const repo = new awsx.ecr.Repository("repo", { - forceDelete: true, -}); - -const image = new awsx.ecr.Image("image", { - repositoryUrl: repo.url, - context: "./app", - platform: "linux/amd64", -}); - -const cluster = new aws.ecs.Cluster("cluster"); -const lb = new awsx.lb.ApplicationLoadBalancer("lb"); - -const service = new awsx.ecs.FargateService("service", { - cluster: cluster.arn, - assignPublicIp: true, - taskDefinitionArgs: { - container: { - name: "my-service", - image: image.imageUri, - cpu: 128, - memory: 512, - essential: true, - portMappings: [{ - containerPort: 80, - targetGroup: lb.defaultTargetGroup, - }], - }, - }, -}); - -exports.url = pulumi.interpolate`http://${lb.loadBalancer.dnsName}`; -``` - -{{% /choosable %}} - -{{% choosable language "typescript" %}} - -```typescript -import * as pulumi from "@pulumi/pulumi"; -import * as aws from "@pulumi/aws"; -import * as awsx from "@pulumi/awsx"; - -const repo = new awsx.ecr.Repository("repo", { - forceDelete: true, -}); - -const image = new awsx.ecr.Image("image", { - repositoryUrl: repo.url, - context: "./app", - platform: "linux/amd64", -}); - -const cluster = new aws.ecs.Cluster("cluster"); -const lb = new awsx.lb.ApplicationLoadBalancer("lb"); - -const service = new awsx.ecs.FargateService("service", { - cluster: cluster.arn, - assignPublicIp: true, - taskDefinitionArgs: { - container: { - name: "my-service", - image: image.imageUri, - cpu: 128, - memory: 512, - essential: true, - portMappings: [{ - containerPort: 80, - targetGroup: lb.defaultTargetGroup, - }], - }, - }, -}); - -export const url = pulumi.interpolate`http://${lb.loadBalancer.dnsName}`; -``` - -{{% /choosable %}} - -{{% choosable language python %}} - -```python -import pulumi -import pulumi_aws as aws -import pulumi_awsx as awsx - -repository = awsx.ecr.Repository( - "repository", - awsx.ecr.RepositoryArgs( - force_delete=True - ), -) - -image = awsx.ecr.Image( - "image", - awsx.ecr.ImageArgs( - repository_url=repository.url, - context="./app", - platform="linux/amd64" - ), -) - -cluster = aws.ecs.Cluster("cluster") -lb = awsx.lb.ApplicationLoadBalancer("lb") - -service = awsx.ecs.FargateService( - "service", - awsx.ecs.FargateServiceArgs( - cluster=cluster.arn, - assign_public_ip=True, - task_definition_args=awsx.ecs.FargateServiceTaskDefinitionArgs( - container=awsx.ecs.TaskDefinitionContainerDefinitionArgs( - name="my-service", - image=image.image_uri, - cpu=128, - memory=512, - essential=True, - port_mappings=[ - awsx.ecs.TaskDefinitionPortMappingArgs( - container_port=80, - target_group=lb.default_target_group, - ) - ], - ), - ), - ), -) - -pulumi.export("url", pulumi.Output.concat("http://", lb.load_balancer.dns_name)) -``` - -{{% /choosable %}} - -{{% choosable language go %}} - -```go -package main - -import ( - "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ecs" - "github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/ecr" - ecsx "github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/ecs" - "github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/lb" - "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -) - -func main() { - pulumi.Run(func(ctx *pulumi.Context) error { - repository, err := ecr.NewRepository(ctx, "repository", &ecr.RepositoryArgs{ - ForceDelete: pulumi.Bool(true), - }) - if err != nil { - return err - } - - image, err := ecr.NewImage(ctx, "image", &ecr.ImageArgs{ - RepositoryUrl: repository.Url, - Context: pulumi.String("./app"), - Platform: pulumi.StringPtr("linux/amd64"), - }) - if err != nil { - return err - } - - 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 = ecsx.NewFargateService(ctx, "service", &ecsx.FargateServiceArgs{ - Cluster: cluster.Arn, - AssignPublicIp: pulumi.Bool(true), - TaskDefinitionArgs: &ecsx.FargateServiceTaskDefinitionArgs{ - Container: &ecsx.TaskDefinitionContainerDefinitionArgs{ - Name: pulumi.String("app"), - Image: image.ImageUri, - Cpu: pulumi.Int(128), - Memory: pulumi.Int(512), - Essential: pulumi.Bool(true), - PortMappings: ecsx.TaskDefinitionPortMappingArray{ - &ecsx.TaskDefinitionPortMappingArgs{ - ContainerPort: pulumi.Int(80), - TargetGroup: lb.DefaultTargetGroup, - }, - }, - }, - }, - }) - if err != nil { - return err - } - - ctx.Export("url", pulumi.Sprintf("http://%s", lb.LoadBalancer.DnsName())) - return nil - }) -} -``` - -{{% /choosable %}} - -{{% choosable language csharp %}} - -```csharp -using System.Collections.Generic; -using Pulumi; -using Aws = Pulumi.Aws; -using Awsx = Pulumi.Awsx; - -return await Deployment.RunAsync(() => -{ - var cluster = new Aws.Ecs.Cluster("cluster"); - - var repo = new Awsx.Ecr.Repository("repo", new() - { - ForceDelete = true, - }); - - var image = new Awsx.Ecr.Image("image", new() - { - RepositoryUrl = repo.Url, - Context = "./app", - Platform = "linux/amd64", - }); - - var lb = new Awsx.Lb.ApplicationLoadBalancer("lb"); - - var service = new Awsx.Ecs.FargateService("service", new Awsx.Ecs.FargateServiceArgs - { - Cluster = cluster.Arn, - AssignPublicIp = true, - TaskDefinitionArgs = new Awsx.Ecs.Inputs.FargateServiceTaskDefinitionArgs - { - Container = new Awsx.Ecs.Inputs.TaskDefinitionContainerDefinitionArgs - { - Name = "my-service", - Image = image.ImageUri, - Cpu = 128, - Memory = 512, - Essential = true, - PortMappings = new[] - { - new Awsx.Ecs.Inputs.TaskDefinitionPortMappingArgs - { - ContainerPort = 80, - TargetGroup = lb.DefaultTargetGroup, - }, - }, - }, - }, - }); - - return new Dictionary - { - ["url"] = lb.LoadBalancer.Apply(loadBalancer => Output.Format($"http://{loadBalancer.DnsName}")), - }; -}); -``` - -{{% /choosable %}} - -{{% choosable language java %}} - -```java -package myproject; - -import com.pulumi.Context; -import com.pulumi.Pulumi; -import com.pulumi.core.Output; -import com.pulumi.awsx.ecr.Repository; -import com.pulumi.awsx.ecr.RepositoryArgs; -import com.pulumi.awsx.ecr.Image; -import com.pulumi.awsx.ecr.ImageArgs; -import com.pulumi.aws.ecs.Cluster; -import com.pulumi.awsx.lb.ApplicationLoadBalancer; -import com.pulumi.awsx.ecs.FargateService; -import com.pulumi.awsx.ecs.FargateServiceArgs; -import com.pulumi.awsx.ecs.inputs.FargateServiceTaskDefinitionArgs; -import com.pulumi.awsx.ecs.inputs.TaskDefinitionContainerDefinitionArgs; -import com.pulumi.awsx.ecs.inputs.TaskDefinitionPortMappingArgs; - -public class App { - public static void main(String[] args) { - Pulumi.run(App::stack); - } - - public static void stack(Context ctx) { - var repository = new Repository("repository", RepositoryArgs.builder() - .forceDelete(true) - .build()); - - var image = new Image("image", ImageArgs.builder() - .repositoryUrl(repository.url()) - .context("./app") - .platform("linux/amd64") - .build()); - - var cluster = new Cluster("cluster"); - - var lb = new ApplicationLoadBalancer("lb"); - - var service = new FargateService("service", FargateServiceArgs.builder() - .cluster(cluster.arn()) - .assignPublicIp(true) - .taskDefinitionArgs(FargateServiceTaskDefinitionArgs.builder() - .container(TaskDefinitionContainerDefinitionArgs.builder() - .name("my-service") - .image(image.imageUri()) - .cpu(128) - .memory(512) - .essential(true) - .portMappings(TaskDefinitionPortMappingArgs.builder() - .containerPort(80) - .targetGroup(lb.defaultTargetGroup()) - .build()) - .build()) - .build()) - .build()); - - ctx.export("url", Output.format("http://%s", lb.loadBalancer().applyValue(loadBalancer -> loadBalancer.dnsName()))); - } -} -``` - -{{% /choosable %}} - -{{% choosable language yaml %}} - -```yaml -name: my-project -runtime: yaml - -resources: - repo: - type: awsx:ecr:Repository - properties: - forceDelete: true - - lb: - type: awsx:lb:ApplicationLoadBalancer - - image: - type: awsx:ecr:Image - properties: - repositoryUrl: ${repo.url} - context: ./app - platform: linux/amd64 - - cluster: - type: aws:ecs:Cluster - - service: - type: awsx:ecs:FargateService - properties: - cluster: ${cluster.arn} - assignPublicIp: true - taskDefinitionArgs: - container: - name: my-service - image: ${image.imageUri} - cpu: 128 - memory: 512 - essential: true - portMappings: - - containerPort: 80 - targetGroup: ${lb.defaultTargetGroup} - -outputs: - url: http://${lb.loadBalancer.dnsName} -``` - -{{% /choosable %}} +{{< example path="load-balanced-fargate-ecr" languages="javascript,typescript,python,go,csharp,java,yaml" >}} For information about ECS, refer to the [Pulumi Crosswalk for AWS ECS documentation](/docs/clouds/aws/guides/ecs/). For information about consuming ECR images from ECS services specifically, see @@ -891,712 +321,7 @@ information about consuming ECR images from ECS services specifically, see To use your private repository from a Kubernetes service, such as one using EKS, reference it like so: -{{< chooser language "javascript,typescript,python,go,csharp,java,yaml" / >}} - -{{% choosable language "javascript" %}} - -```javascript -"use strict"; -const pulumi = require("@pulumi/pulumi"); -const awsx = require("@pulumi/awsx"); -const eks = require("@pulumi/eks"); -const kubernetes = require("@pulumi/kubernetes"); - -const appName = "my-app"; - -const repository = new awsx.ecr.Repository("repository", { - forceDelete: true, -}); - -const image = new awsx.ecr.Image("image", { - repositoryUrl: repository.url, - context: "./app", - platform: "linux/amd64", -}); - -const cluster = new eks.Cluster("cluster"); - -const clusterProvider = new kubernetes.Provider("clusterProvider", { - kubeconfig: cluster.kubeconfig, - enableServerSideApply: true, -}); - -const deployment = new kubernetes.apps.v1.Deployment("deployment", { - metadata: { - labels: { - appClass: appName, - }, - }, - spec: { - replicas: 2, - selector: { - matchLabels: { - appClass: appName, - }, - }, - template: { - metadata: { - labels: { - appClass: appName, - }, - }, - spec: { - containers: [{ - name: appName, - image: image.imageUri, - ports: [{ - name: "http", - containerPort: 80, - }], - }], - }, - }, - }, -}, { - provider: clusterProvider, -}); - -const service = new kubernetes.core.v1.Service("service", { - metadata: { - labels: { - appClass: appName, - }, - }, - spec: { - type: "LoadBalancer", - selector: { - appClass: appName, - }, - ports: [{ - port: 80, - targetPort: "http", - }], - }, -}, { - provider: clusterProvider, -}); - -exports.url = service.status.apply(status => status?.loadBalancer?.ingress?.[0]?.hostname); -``` - -{{% /choosable %}} - -{{% choosable language "typescript" %}} - -```typescript -import * as pulumi from "@pulumi/pulumi"; -import * as awsx from "@pulumi/awsx"; -import * as eks from "@pulumi/eks"; -import * as kubernetes from "@pulumi/kubernetes"; - -const appName = "my-app"; - -const repository = new awsx.ecr.Repository("repository", { - forceDelete: true, -}); - -const image = new awsx.ecr.Image("image", { - repositoryUrl: repository.url, - context: "./app", - platform: "linux/amd64", -}); - -const cluster = new eks.Cluster("cluster"); - -const clusterProvider = new kubernetes.Provider("clusterProvider", { - kubeconfig: cluster.kubeconfig, - enableServerSideApply: true, -}); - -const deployment = new kubernetes.apps.v1.Deployment("deployment", { - metadata: { - labels: { - appClass: appName, - }, - }, - spec: { - replicas: 2, - selector: { - matchLabels: { - appClass: appName, - }, - }, - template: { - metadata: { - labels: { - appClass: appName, - }, - }, - spec: { - containers: [{ - name: appName, - image: image.imageUri, - ports: [{ - name: "http", - containerPort: 80, - }], - }], - }, - }, - }, -}, { - provider: clusterProvider, -}); - -const service = new kubernetes.core.v1.Service("service", { - metadata: { - labels: { - appClass: appName, - }, - }, - spec: { - type: "LoadBalancer", - selector: { - appClass: appName, - }, - ports: [{ - port: 80, - targetPort: "http", - }], - }, -}, { - provider: clusterProvider, -}); - -export const url = service.status.apply(status => status?.loadBalancer?.ingress?.[0]?.hostname); -``` - -{{% /choosable %}} - -{{% choosable language python %}} - -```python -import pulumi -import pulumi_awsx as awsx -import pulumi_eks as eks -import pulumi_kubernetes as kubernetes - -app_name = "my-app" - -repository = awsx.ecr.Repository( - "repository", - awsx.ecr.RepositoryArgs(force_delete=True), -) - -image = awsx.ecr.Image( - "image", - awsx.ecr.ImageArgs( - repository_url=repository.url, context="./app", platform="linux/amd64" - ), -) - -cluster = eks.Cluster("cluster") - -cluster_provider = kubernetes.Provider( - "clusterProvider", kubeconfig=cluster.kubeconfig, enable_server_side_apply=True -) - -deployment = kubernetes.apps.v1.Deployment( - "deployment", - metadata=kubernetes.meta.v1.ObjectMetaArgs( - labels={ - "appClass": app_name, - }, - ), - spec=kubernetes.apps.v1.DeploymentSpecArgs( - replicas=2, - selector=kubernetes.meta.v1.LabelSelectorArgs( - match_labels={ - "appClass": app_name, - }, - ), - template=kubernetes.core.v1.PodTemplateSpecArgs( - metadata=kubernetes.meta.v1.ObjectMetaArgs( - labels={ - "appClass": app_name, - }, - ), - spec=kubernetes.core.v1.PodSpecArgs( - containers=[ - kubernetes.core.v1.ContainerArgs( - name=app_name, - image=image.image_uri, - ports=[ - kubernetes.core.v1.ContainerPortArgs( - name="http", - container_port=80, - ) - ], - ) - ], - ), - ), - ), - opts=pulumi.ResourceOptions(provider=cluster_provider), -) - -service = kubernetes.core.v1.Service( - "service", - metadata=kubernetes.meta.v1.ObjectMetaArgs( - labels={ - "appClass": app_name, - }, - ), - spec=kubernetes.core.v1.ServiceSpecArgs( - type="LoadBalancer", - selector={ - "appClass": app_name, - }, - ports=[ - kubernetes.core.v1.ServicePortArgs( - port=80, - target_port="http", - ) - ], - ), - opts=pulumi.ResourceOptions(provider=cluster_provider), -) - -pulumi.export("url", service.status.load_balancer.ingress[0].hostname) -``` - -{{% /choosable %}} - -{{% choosable language go %}} - -```go -package main - -import ( - "github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/ecr" - "github.com/pulumi/pulumi-eks/sdk/v2/go/eks" - "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes" - appsv1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/apps/v1" - corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/core/v1" - metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/meta/v1" - "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -) - -func main() { - pulumi.Run(func(ctx *pulumi.Context) error { - appName := "my-app" - - repository, err := ecr.NewRepository(ctx, "repository", &ecr.RepositoryArgs{ - ForceDelete: pulumi.Bool(true), - }) - if err != nil { - return err - } - - image, err := ecr.NewImage(ctx, "image", &ecr.ImageArgs{ - RepositoryUrl: repository.Url, - Context: pulumi.String("./app"), - Platform: pulumi.String("linux/amd64"), - }) - if err != nil { - return err - } - - cluster, err := eks.NewCluster(ctx, "cluster", nil) - if err != nil { - return err - } - - clusterProvider, err := kubernetes.NewProvider(ctx, "clusterProvider", &kubernetes.ProviderArgs{ - Kubeconfig: cluster.KubeconfigJson, - EnableServerSideApply: pulumi.Bool(true), - }) - if err != nil { - return err - } - - _, err = appsv1.NewDeployment(ctx, "deployment", &appsv1.DeploymentArgs{ - Metadata: &metav1.ObjectMetaArgs{ - Labels: pulumi.StringMap{ - "appClass": pulumi.String(appName), - }, - }, - Spec: &appsv1.DeploymentSpecArgs{ - Replicas: pulumi.Int(2), - Selector: &metav1.LabelSelectorArgs{ - MatchLabels: pulumi.StringMap{ - "appClass": pulumi.String(appName), - }, - }, - Template: &corev1.PodTemplateSpecArgs{ - Metadata: &metav1.ObjectMetaArgs{ - Labels: pulumi.StringMap{ - "appClass": pulumi.String(appName), - }, - }, - Spec: &corev1.PodSpecArgs{ - Containers: corev1.ContainerArray{ - &corev1.ContainerArgs{ - Name: pulumi.String(appName), - Image: image.ImageUri, - Ports: corev1.ContainerPortArray{ - &corev1.ContainerPortArgs{ - Name: pulumi.String("http"), - ContainerPort: pulumi.Int(80), - }, - }, - }, - }, - }, - }, - }, - }, pulumi.Provider(clusterProvider)) - if err != nil { - return err - } - - service, err := corev1.NewService(ctx, "service", &corev1.ServiceArgs{ - Metadata: &metav1.ObjectMetaArgs{ - Labels: pulumi.StringMap{ - "appClass": pulumi.String(appName), - }, - }, - Spec: &corev1.ServiceSpecArgs{ - Type: pulumi.String("LoadBalancer"), - Selector: pulumi.StringMap{ - "appClass": pulumi.String(appName), - }, - Ports: corev1.ServicePortArray{ - &corev1.ServicePortArgs{ - Port: pulumi.Int(80), - TargetPort: pulumi.Any("http"), - }, - }, - }, - }, pulumi.Provider(clusterProvider)) - if err != nil { - return err - } - - hostname := service.Status.LoadBalancer().Ingress().Index(pulumi.Int(0)).Hostname().Elem() - ctx.Export("url", pulumi.Sprintf("http://%s", hostname)) - - return nil - }) -} -``` - -{{% /choosable %}} - -{{% choosable language csharp %}} - -```csharp -using System.Collections.Generic; -using Pulumi; -using Awsx = Pulumi.Awsx; -using Eks = Pulumi.Eks; -using Kubernetes = Pulumi.Kubernetes; - -return await Deployment.RunAsync(() => -{ - var appName = "my-app"; - - var repository = new Awsx.Ecr.Repository("repository", new() - { - ForceDelete = true, - }); - - var image = new Awsx.Ecr.Image("image", new() - { - RepositoryUrl = repository.Url, - Context = "./app", - Platform = "linux/amd64", - }); - - var cluster = new Eks.Cluster("cluster"); - - var clusterProvider = new Kubernetes.Provider("clusterProvider", new() - { - KubeConfig = cluster.KubeconfigJson, - EnableServerSideApply = true, - }); - - var deployment = new Kubernetes.Apps.V1.Deployment("deployment", new() - { - Metadata = new Kubernetes.Types.Inputs.Meta.V1.ObjectMetaArgs - { - Labels = - { - { "appClass", appName }, - }, - }, - Spec = new Kubernetes.Types.Inputs.Apps.V1.DeploymentSpecArgs - { - Replicas = 2, - Selector = new Kubernetes.Types.Inputs.Meta.V1.LabelSelectorArgs - { - MatchLabels = - { - { "appClass", appName }, - }, - }, - Template = new Kubernetes.Types.Inputs.Core.V1.PodTemplateSpecArgs - { - Metadata = new Kubernetes.Types.Inputs.Meta.V1.ObjectMetaArgs - { - Labels = - { - { "appClass", appName }, - }, - }, - Spec = new Kubernetes.Types.Inputs.Core.V1.PodSpecArgs - { - Containers = new[] - { - new Kubernetes.Types.Inputs.Core.V1.ContainerArgs - { - Name = appName, - Image = image.ImageUri, - Ports = new[] - { - new Kubernetes.Types.Inputs.Core.V1.ContainerPortArgs - { - Name = "http", - ContainerPortValue = 80, - }, - }, - }, - }, - }, - }, - }, - }, new CustomResourceOptions - { - Provider = clusterProvider, - }); - - var service = new Kubernetes.Core.V1.Service("service", new() - { - Metadata = new Kubernetes.Types.Inputs.Meta.V1.ObjectMetaArgs - { - Labels = - { - { "appClass", appName }, - }, - }, - Spec = new Kubernetes.Types.Inputs.Core.V1.ServiceSpecArgs - { - Type = "LoadBalancer", - Selector = - { - { "appClass", appName }, - }, - Ports = new[] - { - new Kubernetes.Types.Inputs.Core.V1.ServicePortArgs - { - Port = 80, - TargetPort = "http", - }, - }, - }, - }, new CustomResourceOptions - { - Provider = clusterProvider, - }); - - var hostname = service.Status.Apply(status => status.LoadBalancer.Ingress[0].Hostname); - - return new Dictionary - { - ["url"] = Output.Format($"http://{hostname}"), - }; -}); -``` - -{{% /choosable %}} - -{{% choosable language java %}} - -```java -package myproject; - -import com.pulumi.Context; -import com.pulumi.Pulumi; -import com.pulumi.core.Output; -import com.pulumi.awsx.ecr.Repository; -import com.pulumi.awsx.ecr.RepositoryArgs; -import com.pulumi.awsx.ecr.Image; -import com.pulumi.awsx.ecr.ImageArgs; -import com.pulumi.eks.Cluster; -import com.pulumi.kubernetes.Provider; -import com.pulumi.kubernetes.ProviderArgs; -import com.pulumi.kubernetes.apps.v1.Deployment; -import com.pulumi.kubernetes.apps.v1.DeploymentArgs; -import com.pulumi.kubernetes.meta.v1.inputs.ObjectMetaArgs; -import com.pulumi.kubernetes.apps.v1.inputs.DeploymentSpecArgs; -import com.pulumi.kubernetes.meta.v1.inputs.LabelSelectorArgs; -import com.pulumi.kubernetes.core.v1.inputs.PodTemplateSpecArgs; -import com.pulumi.kubernetes.core.v1.inputs.ServicePortArgs; -import com.pulumi.kubernetes.core.v1.inputs.ContainerArgs; -import com.pulumi.kubernetes.core.v1.inputs.ContainerPortArgs; -import com.pulumi.kubernetes.core.v1.inputs.PodSpecArgs; -import com.pulumi.kubernetes.core.v1.Service; -import com.pulumi.kubernetes.core.v1.ServiceArgs; -import com.pulumi.kubernetes.core.v1.inputs.ServiceSpecArgs; -import com.pulumi.resources.CustomResourceOptions; -import java.util.Map; - -public class App { - public static void main(String[] args) { - Pulumi.run(App::stack); - } - - public static void stack(Context ctx) { - final var appName = "my-app"; - - var repository = new Repository("repository", RepositoryArgs.builder() - .forceDelete(true) - .build()); - - var image = new Image("image", ImageArgs.builder() - .repositoryUrl(repository.url()) - .context("./app") - .platform("linux/amd64") - .build()); - - var cluster = new Cluster("cluster"); - - var clusterProvider = new Provider("clusterProvider", ProviderArgs.builder() - .kubeconfig(cluster.kubeconfigJson()) - .enableServerSideApply(true) - .build()); - - var deployment = new Deployment("deployment", DeploymentArgs.builder() - .metadata(ObjectMetaArgs.builder() - .labels(Map.of("appClass", appName)) - .build()) - .spec(DeploymentSpecArgs.builder() - .replicas(2) - .selector(LabelSelectorArgs.builder() - .matchLabels(Map.of("appClass", appName)) - .build()) - .template(PodTemplateSpecArgs.builder() - .metadata(ObjectMetaArgs.builder() - .labels(Map.of("appClass", appName)) - .build()) - .spec(PodSpecArgs.builder() - .containers(ContainerArgs.builder() - .name(appName) - .image(image.imageUri()) - .ports(ContainerPortArgs.builder() - .name("http") - .containerPort(80) - .build()) - .build()) - .build()) - .build()) - .build()) - .build(), CustomResourceOptions.builder() - .provider(clusterProvider) - .build()); - - var service = new Service("service", ServiceArgs.builder() - .metadata(ObjectMetaArgs.builder() - .labels(Map.of("appClass", appName)) - .build()) - .spec(ServiceSpecArgs.builder() - .type("LoadBalancer") - .selector(Map.of("appClass", appName)) - .ports(ServicePortArgs.builder() - .port(80) - .targetPort("http") - .build()) - .build()) - .build(), CustomResourceOptions.builder() - .provider(clusterProvider) - .build()); - - ctx.export("url", Output.format("http://%s", service.status().applyValue(status -> { - return status.get().loadBalancer().get().ingress().get(0).hostname().get(); - }))); - } -} -``` - -{{% /choosable %}} - -{{% choosable language yaml %}} - -```yaml -name: my-project -runtime: yaml - -variables: - appName: my-app - -resources: - repository: - type: awsx:ecr:Repository - forceDelete: true - - image: - type: awsx:ecr:Image - properties: - repositoryUrl: ${repository.url} - context: "./app" - platform: "linux/amd64" - - cluster: - type: eks:Cluster - - clusterProvider: - type: pulumi:providers:kubernetes - properties: - kubeconfig: ${cluster.kubeconfigJson} - enableServerSideApply: true - - deployment: - type: kubernetes:apps/v1:Deployment - properties: - metadata: - labels: - appClass: ${appName} - spec: - replicas: 2 - selector: - matchLabels: - appClass: ${appName} - template: - metadata: - labels: - appClass: ${appName} - spec: - containers: - - name: ${appName} - image: ${image.imageUri} - ports: - - name: http - containerPort: 80 - options: - provider: ${clusterProvider} - - service: - type: kubernetes:core/v1:Service - properties: - metadata: - labels: - appClass: ${appName} - spec: - type: LoadBalancer - selector: - appClass: ${appName} - ports: - - port: 80 - targetPort: http - options: - provider: ${clusterProvider} - -outputs: - url: http://${service.status.loadBalancer.ingress[0].hostname} -``` - -{{% /choosable %}} +{{< example path="awsx-ecr-eks-deployment-service" languages="javascript,typescript,python,go,csharp,java,yaml" >}} For information about EKS, refer to the [Pulumi Crosswalk for AWS EKS documentation](/docs/clouds/aws/guides/eks/). diff --git a/themes/default/content/docs/clouds/aws/guides/ecs.md b/themes/default/content/docs/clouds/aws/guides/ecs.md index 6ce8ddbe124..e737482f7b7 100644 --- a/themes/default/content/docs/clouds/aws/guides/ecs.md +++ b/themes/default/content/docs/clouds/aws/guides/ecs.md @@ -44,251 +44,7 @@ providing full control over the underlying EC2 machine resources that power your To run a Docker container in ECS using default network and cluster settings, use the `awsx.ecs.FargateService` class. Since we need to access this container over port 80 using a stable address, we will use a load balancer. -{{< chooser language "typescript,python,go,csharp,java,yaml" / >}} - -{{% choosable language "javascript,typescript" %}} - -```typescript -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 service = new awsx.ecs.FargateService("service", { - cluster: cluster.arn, - assignPublicIp: true, - desiredCount: 2, - taskDefinitionArgs: { - container: { - image: "nginx:latest", - cpu: 512, - memory: 128, - essential: true, - portMappings: [{ - targetGroup: lb.defaultTargetGroup, - }], - }, - }, -}); -export const url = lb.loadBalancer.dnsName; -``` - -{{% /choosable %}} - -{{% choosable language python %}} - -```python -import pulumi -import pulumi_aws as aws -import pulumi_awsx as awsx - -cluster = aws.ecs.Cluster("cluster") -lb = awsx.lb.ApplicationLoadBalancer("lb") -service = awsx.ecs.FargateService("service", - cluster=cluster.arn, - assign_public_ip=True, - desired_count=2, - task_definition_args=awsx.ecs.FargateServiceTaskDefinitionArgs( - container=awsx.ecs.TaskDefinitionContainerDefinitionArgs( - image="nginx:latest", - cpu=512, - memory=128, - essential=True, - port_mappings=[awsx.ecs.TaskDefinitionPortMappingArgs( - target_group=lb.default_target_group, - )], - ), - )) -pulumi.export("url", lb.load_balancer.dns_name) -``` - -{{% /choosable %}} - -{{% choosable language go %}} - -```go -package main - -import ( - "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ecs" - xecs "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 - } - - tdpma := xecs.TaskDefinitionPortMappingArray{ - xecs.TaskDefinitionPortMappingArgs{ - TargetGroup: lb.DefaultTargetGroup, - }, - } - - _, err = xecs.NewFargateService(ctx, "service", &xecs.FargateServiceArgs{ - Cluster: cluster.Arn, - AssignPublicIp: pulumi.Bool(true), - DesiredCount: pulumi.Int(2), - TaskDefinitionArgs: &xecs.FargateServiceTaskDefinitionArgs{ - Container: &xecs.TaskDefinitionContainerDefinitionArgs{ - Image: pulumi.String("nginx:latest"), - Cpu: pulumi.Int(512), - Memory: pulumi.Int(128), - Essential: pulumi.Bool(true), - PortMappings: tdpma, - }, - }, - }) - - if err != nil { - return err - } - ctx.Export("url", lb.LoadBalancer.DnsName()) - return nil - }) -} -``` - -{{% /choosable %}} - -{{% choosable language csharp %}} - -```csharp -using System.Collections.Generic; -using Pulumi; -using Aws = Pulumi.Aws; -using Awsx = Pulumi.Awsx; - -return await Deployment.RunAsync(() => -{ - var cluster = new Aws.Ecs.Cluster("cluster"); - - var lb = new Awsx.Lb.ApplicationLoadBalancer("lb"); - - var service = new Awsx.Ecs.FargateService("service", new() - { - Cluster = cluster.Arn, - AssignPublicIp = true, - DesiredCount = 2, - TaskDefinitionArgs = new Awsx.Ecs.Inputs.FargateServiceTaskDefinitionArgs - { - Container = new Awsx.Ecs.Inputs.TaskDefinitionContainerDefinitionArgs - { - Image = "nginx:latest", - Cpu = 512, - Memory = 128, - Essential = true, - PortMappings = new[] - { - new Awsx.Ecs.Inputs.TaskDefinitionPortMappingArgs - { - TargetGroup = lb.DefaultTargetGroup, - }, - }, - }, - }, - }); - - return new Dictionary - { - ["url"] = lb.LoadBalancer.Apply(loadBalancer => loadBalancer.DnsName), - }; -}); -``` - -{{% /choosable %}} - -{{% choosable language java %}} - -```java -package generated_program; - -import com.pulumi.Context; -import com.pulumi.Pulumi; -import com.pulumi.core.Output; -import com.pulumi.aws.ecs.Cluster; -import com.pulumi.awsx.lb.ApplicationLoadBalancer; -import com.pulumi.awsx.ecs.FargateService; -import com.pulumi.awsx.ecs.FargateServiceArgs; -import com.pulumi.awsx.ecs.inputs.FargateServiceTaskDefinitionArgs; -import com.pulumi.awsx.ecs.inputs.TaskDefinitionContainerDefinitionArgs; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.io.File; -import java.nio.file.Files; -import java.nio.file.Paths; - -public class App { - public static void main(String[] args) { - Pulumi.run(App::stack); - } - - public static void stack(Context ctx) { - var cluster = new Cluster("cluster"); - - var lb = new ApplicationLoadBalancer("lb"); - - var service = new FargateService("service", FargateServiceArgs.builder() - .cluster(cluster.arn()) - .assignPublicIp(true) - .desiredCount(2) - .taskDefinitionArgs(FargateServiceTaskDefinitionArgs.builder() - .container(TaskDefinitionContainerDefinitionArgs.builder() - .image("nginx:latest") - .cpu(512) - .memory(128) - .essential(true) - .portMappings(TaskDefinitionPortMappingArgs.builder() - .targetGroup(lb.defaultTargetGroup()) - .build()) - .build()) - .build()) - .build()); - - ctx.export("url", lb.loadBalancer().applyValue(loadBalancer -> loadBalancer.dnsName())); - } -} -``` - -{{% /choosable %}} - -{{% choosable language yaml %}} - -```yaml -resources: - cluster: - type: aws:ecs:Cluster - lb: - type: awsx:lb:ApplicationLoadBalancer - service: - type: awsx:ecs:FargateService - properties: - cluster: ${cluster.arn} - assignPublicIp: true - desiredCount: 2 - taskDefinitionArgs: - container: - image: nginx:latest - cpu: 512 - memory: 128 - essential: true - portMappings: - - targetGroup: ${lb.defaultTargetGroup} -outputs: - url: ${lb.loadBalancer.dnsName} -``` - -{{% /choosable %}} +{{< example path="load-balanced-fargate-nginx" languages="javascript,typescript,python,go,csharp,java,yaml" >}} After deploying this program, `pulumi stack output url` can be used to access the Url output property. We can then access our NGINX web server behind our load balancer via curl: @@ -327,312 +83,7 @@ To create an ECS service inside of a VPC, we will first create or use an existin described in [Pulumi Crosswalk for AWS VPC](/docs/clouds/aws/guides/vpc/). Then we pass the subnets from that VPC into the network configuration argument for our cluster: -{{< chooser language "typescript,python,go,csharp,java,yaml" / >}} - -{{% choosable language "javascript,typescript" %}} - -```typescript -import * as pulumi from "@pulumi/pulumi"; -import * as aws from "@pulumi/aws"; -import * as awsx from "@pulumi/awsx"; - -const vpc = new awsx.ec2.Vpc("vpc", {}); -const securityGroup = new aws.ec2.SecurityGroup("securityGroup", { - vpcId: vpc.vpcId, - egress: [{ - fromPort: 0, - toPort: 0, - protocol: "-1", - cidrBlocks: ["0.0.0.0/0"], - ipv6CidrBlocks: ["::/0"], - }], -}); -const cluster = new aws.ecs.Cluster("cluster", {}); -const service = new awsx.ecs.FargateService("service", { - cluster: cluster.arn, - networkConfiguration: { - subnets: vpc.privateSubnetIds, - securityGroups: [securityGroup.id], - }, - desiredCount: 2, - taskDefinitionArgs: { - container: { - image: "nginx:latest", - cpu: 512, - memory: 128, - essential: true, - }, - }, -}); -``` - -{{% /choosable %}} - -{{% choosable language python %}} - -```python -import pulumi -import pulumi_aws as aws -import pulumi_awsx as awsx - -vpc = awsx.ec2.Vpc("vpc") -security_group = aws.ec2.SecurityGroup("securityGroup", - vpc_id=vpc.vpc_id, - egress=[aws.ec2.SecurityGroupEgressArgs( - from_port=0, - to_port=0, - protocol="-1", - cidr_blocks=["0.0.0.0/0"], - ipv6_cidr_blocks=["::/0"], - )]) -cluster = aws.ecs.Cluster("cluster") -service = awsx.ecs.FargateService("service", - cluster=cluster.arn, - network_configuration=aws.ecs.ServiceNetworkConfigurationArgs( - subnets=vpc.private_subnet_ids, - security_groups=[security_group.id] - ), - desired_count=2, - task_definition_args=awsx.ecs.FargateServiceTaskDefinitionArgs( - container=awsx.ecs.TaskDefinitionContainerDefinitionArgs( - image="nginx:latest", - cpu=512, - memory=128, - essential=True, - ), - )) -``` - -{{% /choosable %}} - -{{% choosable language go %}} - -```go -package main - -import ( - "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2" - "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ecs" - xec2 "github.com/pulumi/pulumi-awsx/sdk/go/awsx/ec2" - xecs "github.com/pulumi/pulumi-awsx/sdk/go/awsx/ecs" - "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -) - -func main() { - pulumi.Run(func(ctx *pulumi.Context) error { - vpc, err := xec2.NewVpc(ctx, "vpc", nil) - if err != nil { - return err - } - securityGroup, err := ec2.NewSecurityGroup(ctx, "securityGroup", &ec2.SecurityGroupArgs{ - VpcId: vpc.VpcId, - Egress: ec2.SecurityGroupEgressArray{ - &ec2.SecurityGroupEgressArgs{ - FromPort: pulumi.Int(0), - ToPort: pulumi.Int(0), - Protocol: pulumi.String("-1"), - CidrBlocks: pulumi.StringArray{ - pulumi.String("0.0.0.0/0"), - }, - Ipv6CidrBlocks: pulumi.StringArray{ - pulumi.String("::/0"), - }, - }, - }, - }) - if err != nil { - return err - } - cluster, err := ecs.NewCluster(ctx, "cluster", nil) - if err != nil { - return err - } - _, err = xecs.NewFargateService(ctx, "service", &xecs.FargateServiceArgs{ - Cluster: cluster.Arn, - NetworkConfiguration: &ecs.ServiceNetworkConfigurationArgs{ - Subnets: vpc.PrivateSubnetIds, - SecurityGroups: pulumi.StringArray{ - securityGroup.ID(), - }, - }, - DesiredCount: pulumi.Int(2), - TaskDefinitionArgs: &xecs.FargateServiceTaskDefinitionArgs{ - Container: &xecs.TaskDefinitionContainerDefinitionArgs{ - Image: pulumi.String("nginx:latest"), - Cpu: pulumi.Int(512), - Memory: pulumi.Int(128), - Essential: pulumi.Bool(true), - }, - }, - }) - if err != nil { - return err - } - return nil - }) -} -``` - -{{% /choosable %}} - -{{% choosable language csharp %}} - -```csharp -using System.Collections.Generic; -using Pulumi; -using Aws = Pulumi.Aws; -using Awsx = Pulumi.Awsx; - -return await Deployment.RunAsync(() => -{ - var vpc = new Awsx.Ec2.Vpc("vpc"); - - var securityGroup = new Aws.Ec2.SecurityGroup("securityGroup", new() - { - VpcId = vpc.VpcId, - Egress = new[] - { - new Aws.Ec2.Inputs.SecurityGroupEgressArgs - { - FromPort = 0, - ToPort = 0, - Protocol = "-1", - CidrBlocks = new[] - { - "0.0.0.0/0", - }, - Ipv6CidrBlocks = new[] - { - "::/0", - }, - }, - }, - }); - - var cluster = new Aws.Ecs.Cluster("cluster"); - - var service = new Awsx.Ecs.FargateService("service", new() - { - Cluster = cluster.Arn, - NetworkConfiguration = new Aws.Ecs.Inputs.ServiceNetworkConfigurationArgs - { - Subnets = vpc.PrivateSubnetIds, - SecurityGroups = new[] - { - securityGroup.Id, - }, - }, - DesiredCount = 2, - TaskDefinitionArgs = new Awsx.Ecs.Inputs.FargateServiceTaskDefinitionArgs - { - Container = new Awsx.Ecs.Inputs.TaskDefinitionContainerDefinitionArgs - { - Image = "nginx:latest", - Cpu = 512, - Memory = 128, - Essential = true, - }, - }, - }); - -}); -``` - -{{% /choosable %}} - -{{% choosable language java %}} - -```java -package generated_program; - -import com.pulumi.Context; -import com.pulumi.Pulumi; -import com.pulumi.core.Output; -import com.pulumi.aws.ecs.Cluster; -import com.pulumi.awsx.lb.ApplicationLoadBalancer; -import com.pulumi.awsx.ecs.FargateService; -import com.pulumi.awsx.ecs.FargateServiceArgs; -import com.pulumi.awsx.ecs.inputs.FargateServiceTaskDefinitionArgs; -import com.pulumi.awsx.ecs.inputs.TaskDefinitionContainerDefinitionArgs; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.io.File; -import java.nio.file.Files; -import java.nio.file.Paths; - -public class App { - public static void main(String[] args) { - Pulumi.run(App::stack); - } - - public static void stack(Context ctx) { - var cluster = new Cluster("cluster"); - - var lb = new ApplicationLoadBalancer("lb"); - - var service = new FargateService("service", FargateServiceArgs.builder() - .cluster(cluster.arn()) - .assignPublicIp(true) - .desiredCount(2) - .taskDefinitionArgs(FargateServiceTaskDefinitionArgs.builder() - .container(TaskDefinitionContainerDefinitionArgs.builder() - .image("nginx:latest") - .cpu(512) - .memory(128) - .essential(true) - .portMappings(TaskDefinitionPortMappingArgs.builder() - .targetGroup(lb.defaultTargetGroup()) - .build()) - .build()) - .build()) - .build()); - - ctx.export("url", lb.loadBalancer().applyValue(loadBalancer -> loadBalancer.dnsName())); - } -} -``` - -{{% /choosable %}} - -{{% choosable language yaml %}} - -```yaml -resources: - vpc: - type: awsx:ec2:Vpc - securityGroup: - type: aws:ec2:SecurityGroup - properties: - vpcId: ${vpc.vpcId} - egress: - - fromPort: 0 - toPort: 0 - protocol: -1 - cidrBlocks: - - 0.0.0.0/0 - ipv6CidrBlocks: - - "::/0" - cluster: - type: aws:ecs:Cluster - service: - type: awsx:ecs:FargateService - properties: - cluster: ${cluster.arn} - networkConfiguration: - subnets: ${vpc.privateSubnetIds} - securityGroups: - - ${securityGroup.id} - desiredCount: 2 - taskDefinitionArgs: - container: - image: nginx:latest - cpu: 512 - memory: 128 - essential: true -``` - -{{% /choosable %}} +{{< example path="awsx-vpc-fargate-service" languages="javascript,typescript,python,go,csharp,java,yaml" >}} When using a custom VPC, you will also need to specify your own security groups if you need to allow ingress or egress. @@ -663,292 +114,8 @@ it separately ahead of time. This makes it very easy to use private registration For example, specifying a `path` will run a `docker build` in that path, push the result up to the ECR repository that specified in the first argument, and then pass the private ECR repository path to the container: -{{< chooser language "typescript,python,go,csharp,java,yaml" / >}} - -{{% choosable language "javascript,typescript" %}} - -```typescript -import * as pulumi from "@pulumi/pulumi"; -import * as aws from "@pulumi/aws"; -import * as awsx from "@pulumi/awsx"; - -const repository = new awsx.ecr.Repository("repository", {}); -const image = new awsx.ecr.Image("image", { - repositoryUrl: repository.url, - path: "./app", -}); -const cluster = new aws.ecs.Cluster("cluster", {}); -const lb = new awsx.lb.ApplicationLoadBalancer("lb", {}); -const service = new awsx.ecs.FargateService("service", { - cluster: cluster.arn, - assignPublicIp: true, - taskDefinitionArgs: { - container: { - image: image.imageUri, - cpu: 512, - memory: 128, - essential: true, - portMappings: [{ - targetGroup: lb.defaultTargetGroup, - }], - }, - }, -}); -export const url = lb.loadBalancer.dnsName; -``` - -{{% /choosable %}} - -{{% choosable language python %}} - -```python -import pulumi -import pulumi_aws as aws -import pulumi_awsx as awsx - -repository = awsx.ecr.Repository("repository") -image = awsx.ecr.Image("image", - repository_url=repository.url, - path="./app") -cluster = aws.ecs.Cluster("cluster") -lb = awsx.lb.ApplicationLoadBalancer("lb") -service = awsx.ecs.FargateService("service", - cluster=cluster.arn, - assign_public_ip=True, - task_definition_args=awsx.ecs.FargateServiceTaskDefinitionArgs( - container=awsx.ecs.TaskDefinitionContainerDefinitionArgs( - image=image.image_uri, - cpu=512, - memory=128, - essential=True, - port_mappings=[awsx.ecs.TaskDefinitionPortMappingArgs( - target_group=lb.default_target_group, - )], - ), - )) -pulumi.export("url", lb.load_balancer.dns_name) -``` - -{{% /choosable %}} - -{{% choosable language go %}} - -```go -package main - -import ( - "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ecs" - "github.com/pulumi/pulumi-awsx/sdk/go/awsx/ecr" - xecs "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 { - repository, err := ecr.NewRepository(ctx, "repository", nil) - if err != nil { - return err - } - - image, err := ecr.NewImage(ctx, "image", &ecr.ImageArgs{ - RepositoryUrl: repository.Url, - }) - if err != nil { - return err - } - - cluster, err := ecs.NewCluster(ctx, "cluster", nil) - if err != nil { - return err - } - - lb, err := lb.NewApplicationLoadBalancer(ctx, "lb", nil) - if err != nil { - return err - } - - tdpma := xecs.TaskDefinitionPortMappingArray{ - xecs.TaskDefinitionPortMappingArgs{ - TargetGroup: lb.DefaultTargetGroup, - }, - } - _, err = xecs.NewFargateService(ctx, "service", &xecs.FargateServiceArgs{ - Cluster: cluster.Arn, - AssignPublicIp: pulumi.Bool(true), - TaskDefinitionArgs: &xecs.FargateServiceTaskDefinitionArgs{ - Container: &xecs.TaskDefinitionContainerDefinitionArgs{ - Image: image.ImageUri, - Cpu: pulumi.Int(512), - Memory: pulumi.Int(128), - Essential: pulumi.Bool(true), - PortMappings: tdpma, - }, - }, - }) - if err != nil { - return err - } - - ctx.Export("url", lb.LoadBalancer.DnsName()) - return nil - }) -} -``` - -{{% /choosable %}} - -{{% choosable language csharp %}} - -```csharp -using System.Collections.Generic; -using Pulumi; -using Aws = Pulumi.Aws; -using Awsx = Pulumi.Awsx; - -return await Deployment.RunAsync(() => -{ - var repository = new Awsx.Ecr.Repository("repository"); - - var image = new Awsx.Ecr.Image("image", new() - { - RepositoryUrl = repository.Url, - Path = "./app", - }); - - var cluster = new Aws.Ecs.Cluster("cluster"); - - var lb = new Awsx.Lb.ApplicationLoadBalancer("lb"); - - var service = new Awsx.Ecs.FargateService("service", new() - { - Cluster = cluster.Arn, - AssignPublicIp = true, - TaskDefinitionArgs = new Awsx.Ecs.Inputs.FargateServiceTaskDefinitionArgs - { - Container = new Awsx.Ecs.Inputs.TaskDefinitionContainerDefinitionArgs - { - Image = image.ImageUri, - Cpu = 512, - Memory = 128, - Essential = true, - PortMappings = new[] - { - new Awsx.Ecs.Inputs.TaskDefinitionPortMappingArgs - { - TargetGroup = lb.DefaultTargetGroup, - }, - }, - }, - }, - }); - - return new Dictionary - { - ["url"] = lb.LoadBalancer.Apply(loadBalancer => loadBalancer.DnsName), - }; -}); -``` - -{{% /choosable %}} - -{{% choosable language java %}} - -```java -package generated_program; - -import com.pulumi.Context; -import com.pulumi.Pulumi; -import com.pulumi.core.Output; -import com.pulumi.awsx.ecr.Repository; -import com.pulumi.awsx.ecr.Image; -import com.pulumi.awsx.ecr.ImageArgs; -import com.pulumi.aws.ecs.Cluster; -import com.pulumi.awsx.lb.ApplicationLoadBalancer; -import com.pulumi.awsx.ecs.FargateService; -import com.pulumi.awsx.ecs.FargateServiceArgs; -import com.pulumi.awsx.ecs.inputs.FargateServiceTaskDefinitionArgs; -import com.pulumi.awsx.ecs.inputs.TaskDefinitionContainerDefinitionArgs; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.io.File; -import java.nio.file.Files; -import java.nio.file.Paths; - -public class App { - public static void main(String[] args) { - Pulumi.run(App::stack); - } - - public static void stack(Context ctx) { - var repository = new Repository("repository"); - - var image = new Image("image", ImageArgs.builder() - .repositoryUrl(repository.url()) - .path("./app") - .build()); - - var cluster = new Cluster("cluster"); - - var lb = new ApplicationLoadBalancer("lb"); - - var service = new FargateService("service", FargateServiceArgs.builder() - .cluster(cluster.arn()) - .assignPublicIp(true) - .taskDefinitionArgs(FargateServiceTaskDefinitionArgs.builder() - .container(TaskDefinitionContainerDefinitionArgs.builder() - .image(image.imageUri()) - .cpu(512) - .memory(128) - .essential(true) - .portMappings(TaskDefinitionPortMappingArgs.builder() - .targetGroup(lb.defaultTargetGroup()) - .build()) - .build()) - .build()) - .build()); - - ctx.export("url", lb.loadBalancer().applyValue(loadBalancer -> loadBalancer.dnsName())); - } -} -``` - -{{% /choosable %}} - -{{% choosable language yaml %}} - -```yaml -resources: - repository: - type: awsx:ecr:Repository - image: - type: awsx:ecr:Image - properties: - repositoryUrl: ${repository.url} - path: "./app" - cluster: - type: aws:ecs:Cluster - lb: - type: awsx:lb:ApplicationLoadBalancer - service: - type: awsx:ecs:FargateService - properties: - cluster: ${cluster.arn} - assignPublicIp: true - taskDefinitionArgs: - container: - image: ${image.imageUri} - cpu: 512 - memory: 128 - essential: true - portMappings: - - targetGroup: ${lb.defaultTargetGroup} -outputs: - url: ${lb.loadBalancer.dnsName} -``` -{{% /choosable %}} +{{< example path="load-balanced-fargate-ecr" languages="javascript,typescript,python,go,csharp,java,yaml" >}} For more information about using ECR, refer to [Pulumi Crosswalk for AWS ECR](/docs/clouds/aws/guides/ecr/). diff --git a/themes/default/layouts/shortcodes/example.html b/themes/default/layouts/shortcodes/example.html index 7495a65fda4..f6b55e90d0f 100644 --- a/themes/default/layouts/shortcodes/example.html +++ b/themes/default/layouts/shortcodes/example.html @@ -1,3 +1,35 @@ +{{ $path := .Get "path" }} +{{ $languages := .Get "languages" }} +
- {{ .Inner }} +
+ +{{ range $i, $language := split $languages "," }} +
+ +
+ {{ $program := "" }} + {{ if eq $language "javascript" }} + {{ $program = "index.js" }} + {{ else if eq $language "typescript" }} + {{ $program = "index.ts" }} + {{ else if eq $language "python" }} + {{ $program = "__main__.py" }} + {{ else if eq $language "go" }} + {{ $program = "main.go" }} + {{ else if eq $language "csharp" }} + {{ $program = "Program.cs" }} + {{ else if eq $language "java" }} + {{ $program = "src/main/java/myproject/App.java" }} + {{ else if eq $language "yaml" }} + {{ $program = "Pulumi.yaml" }} + {{ end }} + {{ if ne $program "" }} + {{ $code := readFile (path.Join "static" "examples" (printf "%s-%s" $path $language) $program) }} + {{ highlight $code $language }} + {{ end }} +
+
+
+{{ end }} diff --git a/themes/default/layouts/shortcodes/examples.html b/themes/default/layouts/shortcodes/examples.html deleted file mode 100644 index 25c42036219..00000000000 --- a/themes/default/layouts/shortcodes/examples.html +++ /dev/null @@ -1,3 +0,0 @@ -
- {{ .Inner }} -
diff --git a/themes/default/layouts/shortcodes/snippet.html b/themes/default/layouts/shortcodes/snippet.html new file mode 100644 index 00000000000..155d92f4e37 --- /dev/null +++ b/themes/default/layouts/shortcodes/snippet.html @@ -0,0 +1,13 @@ +{{- $path := .Get "path" -}} +{{- $from := .Get "from" -}} +{{- $to := .Get "to" -}} +{{- $file := readFile (path.Join "static" "examples" $path) -}} +{{- if and (ne $from "") (ne $to "") -}} + {{- $lines := split $file "\n" -}} + {{- $toEnd := after (sub (int $from) 1) $lines -}} + {{- $lineCount := add (sub (int $to) (int $from)) 1 -}} + {{- $toTo := first $lineCount $toEnd -}} + {{- delimit $toTo "\n" | safeHTML -}} +{{- else -}} + {{- $file | safeHTML -}} +{{- end -}} diff --git a/themes/default/static/examples/.gitignore b/themes/default/static/examples/.gitignore new file mode 100644 index 00000000000..fd69fc25508 --- /dev/null +++ b/themes/default/static/examples/.gitignore @@ -0,0 +1,370 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc +venv/ + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Java artifacts. +maven-status +target/ + +# Nested .gitignores. +**/.gitignore + +# Lockfiles. +go.sum +package-lock.json +yarn.lock + + +# Stack config files. +Pulumi.*.yaml diff --git a/themes/default/static/examples/README.md b/themes/default/static/examples/README.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-csharp/Program.cs b/themes/default/static/examples/awsx-ecr-eks-deployment-service-csharp/Program.cs new file mode 100644 index 00000000000..a91750d9665 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-csharp/Program.cs @@ -0,0 +1,121 @@ +using System.Collections.Generic; +using Pulumi; +using Awsx = Pulumi.Awsx; +using Eks = Pulumi.Eks; +using Kubernetes = Pulumi.Kubernetes; + +return await Deployment.RunAsync(() => +{ + var appName = "my-app"; + + var repository = new Awsx.Ecr.Repository("repository", new() + { + ForceDelete = true, + }); + + var image = new Awsx.Ecr.Image("image", new() + { + RepositoryUrl = repository.Url, + Context = "./app", + Platform = "linux/amd64", + }); + + var cluster = new Eks.Cluster("cluster"); + + var clusterProvider = new Kubernetes.Provider("clusterProvider", new() + { + KubeConfig = cluster.KubeconfigJson, + EnableServerSideApply = true, + }); + + var deployment = new Kubernetes.Apps.V1.Deployment("deployment", new() + { + Metadata = new Kubernetes.Types.Inputs.Meta.V1.ObjectMetaArgs + { + Labels = + { + { "appClass", appName }, + }, + }, + Spec = new Kubernetes.Types.Inputs.Apps.V1.DeploymentSpecArgs + { + Replicas = 2, + Selector = new Kubernetes.Types.Inputs.Meta.V1.LabelSelectorArgs + { + MatchLabels = + { + { "appClass", appName }, + }, + }, + Template = new Kubernetes.Types.Inputs.Core.V1.PodTemplateSpecArgs + { + Metadata = new Kubernetes.Types.Inputs.Meta.V1.ObjectMetaArgs + { + Labels = + { + { "appClass", appName }, + }, + }, + Spec = new Kubernetes.Types.Inputs.Core.V1.PodSpecArgs + { + Containers = new[] + { + new Kubernetes.Types.Inputs.Core.V1.ContainerArgs + { + Name = appName, + Image = image.ImageUri, + Ports = new[] + { + new Kubernetes.Types.Inputs.Core.V1.ContainerPortArgs + { + Name = "http", + ContainerPortValue = 80, + }, + }, + }, + }, + }, + }, + }, + }, new CustomResourceOptions + { + Provider = clusterProvider, + }); + + var service = new Kubernetes.Core.V1.Service("service", new() + { + Metadata = new Kubernetes.Types.Inputs.Meta.V1.ObjectMetaArgs + { + Labels = + { + { "appClass", appName }, + }, + }, + Spec = new Kubernetes.Types.Inputs.Core.V1.ServiceSpecArgs + { + Type = "LoadBalancer", + Selector = + { + { "appClass", appName }, + }, + Ports = new[] + { + new Kubernetes.Types.Inputs.Core.V1.ServicePortArgs + { + Port = 80, + TargetPort = "http", + }, + }, + }, + }, new CustomResourceOptions + { + Provider = clusterProvider, + }); + + var hostname = service.Status.Apply(status => status.LoadBalancer.Ingress[0].Hostname); + + return new Dictionary + { + ["url"] = Output.Format($"http://{hostname}"), + }; +}); diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-csharp/Pulumi.yaml b/themes/default/static/examples/awsx-ecr-eks-deployment-service-csharp/Pulumi.yaml new file mode 100644 index 00000000000..3d70acd4f1d --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-csharp/Pulumi.yaml @@ -0,0 +1,3 @@ +name: awsx-ecr-eks-deployment-service-csharp +runtime: dotnet +description: A C# program to deploy a Kubernetes cluster on AWS diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-csharp/app/Dockerfile b/themes/default/static/examples/awsx-ecr-eks-deployment-service-csharp/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-csharp/app/Dockerfile @@ -0,0 +1 @@ +FROM nginx \ No newline at end of file diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-csharp/awsx-ecr-eks-deployment-service-csharp.csproj b/themes/default/static/examples/awsx-ecr-eks-deployment-service-csharp/awsx-ecr-eks-deployment-service-csharp.csproj new file mode 100644 index 00000000000..c240a9cdf55 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-csharp/awsx-ecr-eks-deployment-service-csharp.csproj @@ -0,0 +1,17 @@ + + + + Exe + net6.0 + enable + + + + + + + + + + + diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-go/Pulumi.yaml b/themes/default/static/examples/awsx-ecr-eks-deployment-service-go/Pulumi.yaml new file mode 100644 index 00000000000..787a3e6b0bf --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-go/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-ecr-eks-deployment-service-go +runtime: go diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-go/go.mod b/themes/default/static/examples/awsx-ecr-eks-deployment-service-go/go.mod new file mode 100644 index 00000000000..8c1f065a814 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-go/go.mod @@ -0,0 +1,97 @@ +module awsx-ecr-eks-deployment-service-yaml + +go 1.21 + +toolchain go1.21.0 + +require ( + github.com/pulumi/pulumi-awsx/sdk/v2 v2.2.0 + github.com/pulumi/pulumi-eks/sdk/v2 v2.0.0 + github.com/pulumi/pulumi-kubernetes/sdk/v4 v4.5.4 + github.com/pulumi/pulumi/sdk/v3 v3.92.0 +) + +require ( + dario.cat/mergo v1.0.0 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect + github.com/acomagu/bufpipe v1.0.4 // indirect + github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect + github.com/agext/levenshtein v1.2.3 // indirect + github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/atotto/clipboard v0.1.4 // indirect + github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect + github.com/blang/semver v3.5.1+incompatible // indirect + github.com/charmbracelet/bubbles v0.16.1 // indirect + github.com/charmbracelet/bubbletea v0.24.2 // indirect + github.com/charmbracelet/lipgloss v0.7.1 // indirect + github.com/cheggaaa/pb v1.0.29 // indirect + github.com/cloudflare/circl v1.3.3 // indirect + github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect + github.com/cyphar/filepath-securejoin v0.2.4 // indirect + github.com/djherbis/times v1.5.0 // indirect + github.com/emirpasic/gods v1.18.1 // indirect + github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect + github.com/go-git/go-billy/v5 v5.5.0 // indirect + github.com/go-git/go-git/v5 v5.9.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/glog v1.1.0 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/hashicorp/hcl/v2 v2.17.0 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect + github.com/kevinburke/ssh_config v1.2.0 // indirect + github.com/lucasb-eyer/go-colorful v1.2.0 // indirect + github.com/mattn/go-isatty v0.0.18 // indirect + github.com/mattn/go-localereader v0.0.1 // indirect + github.com/mattn/go-runewidth v0.0.14 // indirect + github.com/mitchellh/go-ps v1.0.0 // indirect + github.com/mitchellh/go-wordwrap v1.0.1 // indirect + github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect + github.com/muesli/cancelreader v0.2.2 // indirect + github.com/muesli/reflow v0.3.0 // indirect + github.com/muesli/termenv v0.15.1 // indirect + github.com/opentracing/basictracer-go v1.1.0 // indirect + github.com/opentracing/opentracing-go v1.2.0 // indirect + github.com/pjbgf/sha1cd v0.3.0 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/pkg/term v1.1.0 // indirect + github.com/pulumi/esc v0.5.6 // indirect + github.com/pulumi/pulumi-aws/sdk/v6 v6.7.0 // indirect + github.com/pulumi/pulumi-docker/sdk/v4 v4.4.3 // indirect + github.com/rivo/uniseg v0.4.4 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect + github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect + github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect + github.com/sergi/go-diff v1.3.1 // indirect + github.com/skeema/knownhosts v1.2.0 // indirect + github.com/spf13/cobra v1.7.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/texttheater/golang-levenshtein v1.0.1 // indirect + github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 // indirect + github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect + github.com/uber/jaeger-lib v2.4.1+incompatible // indirect + github.com/xanzy/ssh-agent v0.3.3 // indirect + github.com/zclconf/go-cty v1.13.2 // indirect + go.uber.org/atomic v1.9.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect + golang.org/x/mod v0.13.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sync v0.4.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/term v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect + golang.org/x/tools v0.14.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d // indirect + google.golang.org/grpc v1.57.1 // indirect + google.golang.org/protobuf v1.31.0 // indirect + gopkg.in/warnings.v0 v0.1.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + lukechampine.com/frand v1.4.2 // indirect + sourcegraph.com/sourcegraph/appdash v0.0.0-20211028080628-e2786a622600 // indirect +) diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-go/main.go b/themes/default/static/examples/awsx-ecr-eks-deployment-service-go/main.go new file mode 100644 index 00000000000..9d462ae84a3 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-go/main.go @@ -0,0 +1,114 @@ +package main + +import ( + "github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/ecr" + "github.com/pulumi/pulumi-eks/sdk/v2/go/eks" + "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes" + appsv1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/apps/v1" + corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/core/v1" + metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/meta/v1" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + appName := "my-app" + + repository, err := ecr.NewRepository(ctx, "repository", &ecr.RepositoryArgs{ + ForceDelete: pulumi.Bool(true), + }) + if err != nil { + return err + } + + image, err := ecr.NewImage(ctx, "image", &ecr.ImageArgs{ + RepositoryUrl: repository.Url, + Context: pulumi.String("./app"), + Platform: pulumi.String("linux/amd64"), + }) + if err != nil { + return err + } + + cluster, err := eks.NewCluster(ctx, "cluster", nil) + if err != nil { + return err + } + + clusterProvider, err := kubernetes.NewProvider(ctx, "clusterProvider", &kubernetes.ProviderArgs{ + Kubeconfig: cluster.KubeconfigJson, + EnableServerSideApply: pulumi.Bool(true), + }) + if err != nil { + return err + } + + _, err = appsv1.NewDeployment(ctx, "deployment", &appsv1.DeploymentArgs{ + Metadata: &metav1.ObjectMetaArgs{ + Labels: pulumi.StringMap{ + "appClass": pulumi.String(appName), + }, + }, + Spec: &appsv1.DeploymentSpecArgs{ + Replicas: pulumi.Int(2), + Selector: &metav1.LabelSelectorArgs{ + MatchLabels: pulumi.StringMap{ + "appClass": pulumi.String(appName), + }, + }, + Template: &corev1.PodTemplateSpecArgs{ + Metadata: &metav1.ObjectMetaArgs{ + Labels: pulumi.StringMap{ + "appClass": pulumi.String(appName), + }, + }, + Spec: &corev1.PodSpecArgs{ + Containers: corev1.ContainerArray{ + &corev1.ContainerArgs{ + Name: pulumi.String(appName), + Image: image.ImageUri, + Ports: corev1.ContainerPortArray{ + &corev1.ContainerPortArgs{ + Name: pulumi.String("http"), + ContainerPort: pulumi.Int(80), + }, + }, + }, + }, + }, + }, + }, + }, pulumi.Provider(clusterProvider)) + if err != nil { + return err + } + + service, err := corev1.NewService(ctx, "service", &corev1.ServiceArgs{ + Metadata: &metav1.ObjectMetaArgs{ + Labels: pulumi.StringMap{ + "appClass": pulumi.String(appName), + }, + }, + Spec: &corev1.ServiceSpecArgs{ + Type: pulumi.String("LoadBalancer"), + Selector: pulumi.StringMap{ + "appClass": pulumi.String(appName), + }, + Ports: corev1.ServicePortArray{ + &corev1.ServicePortArgs{ + Port: pulumi.Int(80), + TargetPort: pulumi.Any("http"), + }, + }, + }, + }, pulumi.Provider(clusterProvider)) + if err != nil { + return err + } + + hostname := service.Status.LoadBalancer().Ingress().Index(pulumi.Int(0)).Hostname().Elem() + ctx.Export("url", pulumi.Sprintf("http://%s", hostname)) + + return nil + }) +} diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-java/Pulumi.yaml b/themes/default/static/examples/awsx-ecr-eks-deployment-service-java/Pulumi.yaml new file mode 100644 index 00000000000..df81f7e2cec --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-java/Pulumi.yaml @@ -0,0 +1,3 @@ +name: awsx-ecr-eks-deployment-service-java +runtime: java +description: A minimal AWS Java Pulumi program diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-java/app/Dockerfile b/themes/default/static/examples/awsx-ecr-eks-deployment-service-java/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-java/app/Dockerfile @@ -0,0 +1 @@ +FROM nginx \ No newline at end of file diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-java/pom.xml b/themes/default/static/examples/awsx-ecr-eks-deployment-service-java/pom.xml new file mode 100644 index 00000000000..a75a8e78bcb --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-java/pom.xml @@ -0,0 +1,107 @@ + + + 4.0.0 + + com.pulumi + awsx-ecr-eks-deployment-service-java + 1.0-SNAPSHOT + + + UTF-8 + 11 + 11 + 11 + myproject.App + + + + + + com.pulumi + pulumi + (,1.0] + + + com.pulumi + aws + (6.0.2,6.99] + + + com.pulumi + awsx + (2.0.0,2.99] + + + com.pulumi + eks + (2.0.0,2.99] + + + com.pulumi + kubernetes + (4.0.0,4.99] + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.2 + + + + true + ${mainClass} + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.3.0 + + + + true + ${mainClass} + + + + jar-with-dependencies + + + + + make-my-jar-with-dependencies + package + + single + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.0.0 + + ${mainClass} + ${mainArgs} + + + + org.apache.maven.plugins + maven-wrapper-plugin + 3.1.0 + + 3.8.5 + + + + + diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-java/src/main/java/myproject/App.java b/themes/default/static/examples/awsx-ecr-eks-deployment-service-java/src/main/java/myproject/App.java new file mode 100644 index 00000000000..844cf7dfb67 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-java/src/main/java/myproject/App.java @@ -0,0 +1,103 @@ +package myproject; + +import com.pulumi.Context; +import com.pulumi.Pulumi; +import com.pulumi.core.Output; +import com.pulumi.awsx.ecr.Repository; +import com.pulumi.awsx.ecr.RepositoryArgs; +import com.pulumi.awsx.ecr.Image; +import com.pulumi.awsx.ecr.ImageArgs; +import com.pulumi.eks.Cluster; +import com.pulumi.kubernetes.Provider; +import com.pulumi.kubernetes.ProviderArgs; +import com.pulumi.kubernetes.apps.v1.Deployment; +import com.pulumi.kubernetes.apps.v1.DeploymentArgs; +import com.pulumi.kubernetes.meta.v1.inputs.ObjectMetaArgs; +import com.pulumi.kubernetes.apps.v1.inputs.DeploymentSpecArgs; +import com.pulumi.kubernetes.meta.v1.inputs.LabelSelectorArgs; +import com.pulumi.kubernetes.core.v1.inputs.PodTemplateSpecArgs; +import com.pulumi.kubernetes.core.v1.inputs.ServicePortArgs; +import com.pulumi.kubernetes.core.v1.inputs.ContainerArgs; +import com.pulumi.kubernetes.core.v1.inputs.ContainerPortArgs; +import com.pulumi.kubernetes.core.v1.inputs.PodSpecArgs; +import com.pulumi.kubernetes.core.v1.Service; +import com.pulumi.kubernetes.core.v1.ServiceArgs; +import com.pulumi.kubernetes.core.v1.inputs.ServiceSpecArgs; +import com.pulumi.resources.CustomResourceOptions; +import java.util.Map; + +public class App { + public static void main(String[] args) { + Pulumi.run(App::stack); + } + + public static void stack(Context ctx) { + final var appName = "my-app"; + + var repository = new Repository("repository", RepositoryArgs.builder() + .forceDelete(true) + .build()); + + var image = new Image("image", ImageArgs.builder() + .repositoryUrl(repository.url()) + .context("./app") + .platform("linux/amd64") + .build()); + + var cluster = new Cluster("cluster"); + + var clusterProvider = new Provider("clusterProvider", ProviderArgs.builder() + .kubeconfig(cluster.kubeconfigJson()) + .enableServerSideApply(true) + .build()); + + var deployment = new Deployment("deployment", DeploymentArgs.builder() + .metadata(ObjectMetaArgs.builder() + .labels(Map.of("appClass", appName)) + .build()) + .spec(DeploymentSpecArgs.builder() + .replicas(2) + .selector(LabelSelectorArgs.builder() + .matchLabels(Map.of("appClass", appName)) + .build()) + .template(PodTemplateSpecArgs.builder() + .metadata(ObjectMetaArgs.builder() + .labels(Map.of("appClass", appName)) + .build()) + .spec(PodSpecArgs.builder() + .containers(ContainerArgs.builder() + .name(appName) + .image(image.imageUri()) + .ports(ContainerPortArgs.builder() + .name("http") + .containerPort(80) + .build()) + .build()) + .build()) + .build()) + .build()) + .build(), CustomResourceOptions.builder() + .provider(clusterProvider) + .build()); + + var service = new Service("service", ServiceArgs.builder() + .metadata(ObjectMetaArgs.builder() + .labels(Map.of("appClass", appName)) + .build()) + .spec(ServiceSpecArgs.builder() + .type("LoadBalancer") + .selector(Map.of("appClass", appName)) + .ports(ServicePortArgs.builder() + .port(80) + .targetPort("http") + .build()) + .build()) + .build(), CustomResourceOptions.builder() + .provider(clusterProvider) + .build()); + + ctx.export("url", Output.format("http://%s", service.status().applyValue(status -> { + return status.get().loadBalancer().get().ingress().get(0).hostname().get(); + }))); + } +} diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-javascript/Pulumi.yaml b/themes/default/static/examples/awsx-ecr-eks-deployment-service-javascript/Pulumi.yaml new file mode 100644 index 00000000000..8eb1f8d881a --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-javascript/Pulumi.yaml @@ -0,0 +1,5 @@ +name: awsx-ecr-eks-deployment-service-javascript +runtime: + name: nodejs + options: + typescript: false diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-javascript/index.js b/themes/default/static/examples/awsx-ecr-eks-deployment-service-javascript/index.js new file mode 100644 index 00000000000..c3867aa778c --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-javascript/index.js @@ -0,0 +1,81 @@ +"use strict"; +const pulumi = require("@pulumi/pulumi"); +const awsx = require("@pulumi/awsx"); +const eks = require("@pulumi/eks"); +const kubernetes = require("@pulumi/kubernetes"); + +const appName = "my-app"; + +const repository = new awsx.ecr.Repository("repository", { + forceDelete: true, +}); + +const image = new awsx.ecr.Image("image", { + repositoryUrl: repository.url, + context: "./app", + platform: "linux/amd64", +}); + +const cluster = new eks.Cluster("cluster"); + +const clusterProvider = new kubernetes.Provider("clusterProvider", { + kubeconfig: cluster.kubeconfig, + enableServerSideApply: true, +}); + +const deployment = new kubernetes.apps.v1.Deployment("deployment", { + metadata: { + labels: { + appClass: appName, + }, + }, + spec: { + replicas: 2, + selector: { + matchLabels: { + appClass: appName, + }, + }, + template: { + metadata: { + labels: { + appClass: appName, + }, + }, + spec: { + containers: [{ + name: appName, + image: image.imageUri, + ports: [{ + name: "http", + containerPort: 80, + }], + }], + }, + }, + }, +}, { + provider: clusterProvider, +}); + +const service = new kubernetes.core.v1.Service("service", { + metadata: { + labels: { + appClass: appName, + }, + }, + spec: { + type: "LoadBalancer", + selector: { + appClass: appName, + }, + ports: [{ + port: 80, + targetPort: "http", + }], + }, +}, { + provider: clusterProvider, +}); + +exports.url = service.status.apply(status => status?.loadBalancer?.ingress?.[0]?.hostname); diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-javascript/package.json b/themes/default/static/examples/awsx-ecr-eks-deployment-service-javascript/package.json new file mode 100644 index 00000000000..e05af511ac7 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-javascript/package.json @@ -0,0 +1,13 @@ +{ + "name": "awsx-ecr-eks-deployment-service-javascript", + "devDependencies": { + "@types/node": "^14" + }, + "dependencies": { + "typescript": "^4.0.0", + "@pulumi/pulumi": "^3.0.0", + "@pulumi/awsx": "^2.0.0", + "@pulumi/eks": "^2.0.0", + "@pulumi/kubernetes": "^4.0.0" + } +} diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-python/Pulumi.yaml b/themes/default/static/examples/awsx-ecr-eks-deployment-service-python/Pulumi.yaml new file mode 100644 index 00000000000..fa8a4a5f7dc --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-python/Pulumi.yaml @@ -0,0 +1,6 @@ +name: awsx-ecr-eks-deployment-service-python +runtime: + name: python + options: + virtualenv: venv +description: A Python program to deploy a Kubernetes cluster on AWS diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-python/__main__.py b/themes/default/static/examples/awsx-ecr-eks-deployment-service-python/__main__.py new file mode 100644 index 00000000000..feb4a43c090 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-python/__main__.py @@ -0,0 +1,87 @@ +import pulumi +import pulumi_awsx as awsx +import pulumi_eks as eks +import pulumi_kubernetes as kubernetes + +app_name = "my-app" + +repository = awsx.ecr.Repository( + "repository", + awsx.ecr.RepositoryArgs(force_delete=True), +) + +image = awsx.ecr.Image( + "image", + awsx.ecr.ImageArgs( + repository_url=repository.url, context="./app", platform="linux/amd64" + ), +) + +cluster = eks.Cluster("cluster") + +cluster_provider = kubernetes.Provider( + "clusterProvider", kubeconfig=cluster.kubeconfig, enable_server_side_apply=True +) + +deployment = kubernetes.apps.v1.Deployment( + "deployment", + metadata=kubernetes.meta.v1.ObjectMetaArgs( + labels={ + "appClass": app_name, + }, + ), + spec=kubernetes.apps.v1.DeploymentSpecArgs( + replicas=2, + selector=kubernetes.meta.v1.LabelSelectorArgs( + match_labels={ + "appClass": app_name, + }, + ), + template=kubernetes.core.v1.PodTemplateSpecArgs( + metadata=kubernetes.meta.v1.ObjectMetaArgs( + labels={ + "appClass": app_name, + }, + ), + spec=kubernetes.core.v1.PodSpecArgs( + containers=[ + kubernetes.core.v1.ContainerArgs( + name=app_name, + image=image.image_uri, + ports=[ + kubernetes.core.v1.ContainerPortArgs( + name="http", + container_port=80, + ) + ], + ), + ], + ), + ), + ), + opts=pulumi.ResourceOptions(provider=cluster_provider), +) + +service = kubernetes.core.v1.Service( + "service", + metadata=kubernetes.meta.v1.ObjectMetaArgs( + labels={ + "appClass": app_name, + }, + ), + spec=kubernetes.core.v1.ServiceSpecArgs( + type="LoadBalancer", + selector={ + "appClass": app_name, + }, + ports=[ + kubernetes.core.v1.ServicePortArgs( + port=80, + target_port="http", + ) + ], + ), + opts=pulumi.ResourceOptions(provider=cluster_provider), +) + +pulumi.export("url", service.status.load_balancer.ingress[0].hostname) diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-python/app/Dockerfile b/themes/default/static/examples/awsx-ecr-eks-deployment-service-python/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-python/app/Dockerfile @@ -0,0 +1 @@ +FROM nginx \ No newline at end of file diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-python/requirements.txt b/themes/default/static/examples/awsx-ecr-eks-deployment-service-python/requirements.txt new file mode 100644 index 00000000000..e2cdbc80eb6 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-python/requirements.txt @@ -0,0 +1,3 @@ +pulumi>=3.0.0,<4.0.0 +pulumi-awsx>=2.0.0,<3.0.0 +pulumi-eks>=2.0.0,<3.0.0 diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-typescript/Pulumi.yaml b/themes/default/static/examples/awsx-ecr-eks-deployment-service-typescript/Pulumi.yaml new file mode 100644 index 00000000000..705d13bb168 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-typescript/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-ecr-eks-deployment-service-typescript +runtime: nodejs diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-typescript/index.ts b/themes/default/static/examples/awsx-ecr-eks-deployment-service-typescript/index.ts new file mode 100644 index 00000000000..1b154f2d57d --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-typescript/index.ts @@ -0,0 +1,80 @@ +import * as pulumi from "@pulumi/pulumi"; +import * as awsx from "@pulumi/awsx"; +import * as eks from "@pulumi/eks"; +import * as kubernetes from "@pulumi/kubernetes"; + +const appName = "my-app"; + +const repository = new awsx.ecr.Repository("repository", { + forceDelete: true, +}); + +const image = new awsx.ecr.Image("image", { + repositoryUrl: repository.url, + context: "./app", + platform: "linux/amd64", +}); + +const cluster = new eks.Cluster("cluster"); + +const clusterProvider = new kubernetes.Provider("clusterProvider", { + kubeconfig: cluster.kubeconfig, + enableServerSideApply: true, +}); + +const deployment = new kubernetes.apps.v1.Deployment("deployment", { + metadata: { + labels: { + appClass: appName, + }, + }, + spec: { + replicas: 2, + selector: { + matchLabels: { + appClass: appName, + }, + }, + template: { + metadata: { + labels: { + appClass: appName, + }, + }, + spec: { + containers: [{ + name: appName, + image: image.imageUri, + ports: [{ + name: "http", + containerPort: 80, + }], + }], + }, + }, + }, +}, { + provider: clusterProvider, +}); + +const service = new kubernetes.core.v1.Service("service", { + metadata: { + labels: { + appClass: appName, + }, + }, + spec: { + type: "LoadBalancer", + selector: { + appClass: appName, + }, + ports: [{ + port: 80, + targetPort: "http", + }], + }, +}, { + provider: clusterProvider, +}); + +export const url = service.status.apply(status => status?.loadBalancer?.ingress?.[0]?.hostname); diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-typescript/package.json b/themes/default/static/examples/awsx-ecr-eks-deployment-service-typescript/package.json new file mode 100644 index 00000000000..8c4c905596d --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-typescript/package.json @@ -0,0 +1,13 @@ +{ + "name": "awsx-ecr-eks-deployment-service-typescript", + "devDependencies": { + "@types/node": "^14" + }, + "dependencies": { + "typescript": "^4.0.0", + "@pulumi/pulumi": "^3.0.0", + "@pulumi/awsx": "^2.0.0", + "@pulumi/eks": "^2.0.0", + "@pulumi/kubernetes": "^4.0.0" + } +} diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-typescript/tsconfig.json b/themes/default/static/examples/awsx-ecr-eks-deployment-service-typescript/tsconfig.json new file mode 100644 index 00000000000..11fc69af240 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-typescript/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "strict": true, + "outDir": "bin", + "target": "es2016", + "module": "commonjs", + "moduleResolution": "node", + "sourceMap": true, + "experimentalDecorators": true, + "pretty": true, + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.ts", + ] +} \ No newline at end of file diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-yaml/Pulumi.yaml b/themes/default/static/examples/awsx-ecr-eks-deployment-service-yaml/Pulumi.yaml new file mode 100644 index 00000000000..403c1b5460e --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-yaml/Pulumi.yaml @@ -0,0 +1,69 @@ +name: awsx-ecr-eks-deployment-service-yaml +runtime: yaml + +variables: + appName: my-app + +resources: + repository: + type: awsx:ecr:Repository + + image: + type: awsx:ecr:Image + properties: + repositoryUrl: ${repository.url} + context: "./app" + platform: "linux/amd64" + + cluster: + type: eks:Cluster + + clusterProvider: + type: pulumi:providers:kubernetes + properties: + kubeconfig: ${cluster.kubeconfigJson} + enableServerSideApply: true + + deployment: + type: kubernetes:apps/v1:Deployment + properties: + metadata: + labels: + appClass: ${appName} + spec: + replicas: 2 + selector: + matchLabels: + appClass: ${appName} + template: + metadata: + labels: + appClass: ${appName} + spec: + containers: + - name: ${appName} + image: ${image.imageUri} + ports: + - name: http + containerPort: 80 + options: + provider: ${clusterProvider} + + service: + type: kubernetes:core/v1:Service + properties: + metadata: + labels: + appClass: ${appName} + spec: + type: LoadBalancer + selector: + appClass: ${appName} + ports: + - port: 80 + targetPort: http + options: + provider: ${clusterProvider} + +outputs: + url: http://${service.status.loadBalancer.ingress[0].hostname} diff --git a/themes/default/static/examples/awsx-ecr-eks-deployment-service-yaml/app/Dockerfile b/themes/default/static/examples/awsx-ecr-eks-deployment-service-yaml/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-eks-deployment-service-yaml/app/Dockerfile @@ -0,0 +1 @@ +FROM nginx \ No newline at end of file diff --git a/themes/default/static/examples/awsx-ecr-image-csharp/Program.cs b/themes/default/static/examples/awsx-ecr-image-csharp/Program.cs new file mode 100644 index 00000000000..b341a8cd540 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-csharp/Program.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using Pulumi; +using Awsx = Pulumi.Awsx; + +return await Deployment.RunAsync(() => +{ + var repository = new Awsx.Ecr.Repository("repository", new() + { + ForceDelete = true, + }); + + var image = new Awsx.Ecr.Image("image", new() + { + RepositoryUrl = repository.Url, + Context = "./app", + Platform = "linux/amd64", + }); + + return new Dictionary + { + ["url"] = repository.Url, + }; +}); diff --git a/themes/default/static/examples/awsx-ecr-image-csharp/Pulumi.yaml b/themes/default/static/examples/awsx-ecr-image-csharp/Pulumi.yaml new file mode 100644 index 00000000000..cf64e680786 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-csharp/Pulumi.yaml @@ -0,0 +1,3 @@ +name: awsx-ecr-image-csharp +runtime: dotnet +description: A minimal AWS C# Pulumi program haha no. diff --git a/themes/default/static/examples/awsx-ecr-image-csharp/app/Dockerfile b/themes/default/static/examples/awsx-ecr-image-csharp/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-csharp/app/Dockerfile @@ -0,0 +1 @@ +FROM nginx \ No newline at end of file diff --git a/themes/default/static/examples/awsx-ecr-image-csharp/awsx-ecr-image-csharp.csproj b/themes/default/static/examples/awsx-ecr-image-csharp/awsx-ecr-image-csharp.csproj new file mode 100644 index 00000000000..ac10d4fba32 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-csharp/awsx-ecr-image-csharp.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + enable + + + + + + + + + diff --git a/themes/default/static/examples/awsx-ecr-image-go/Pulumi.yaml b/themes/default/static/examples/awsx-ecr-image-go/Pulumi.yaml new file mode 100644 index 00000000000..5999dfc886e --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-go/Pulumi.yaml @@ -0,0 +1,3 @@ +name: awsx-ecr-image-go +runtime: go +description: A minimal AWS Go Pulumi program diff --git a/themes/default/static/examples/awsx-ecr-image-go/app/Dockerfile b/themes/default/static/examples/awsx-ecr-image-go/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-go/app/Dockerfile @@ -0,0 +1 @@ +FROM nginx \ No newline at end of file diff --git a/themes/default/static/examples/awsx-ecr-image-go/go.mod b/themes/default/static/examples/awsx-ecr-image-go/go.mod new file mode 100644 index 00000000000..49627583596 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-go/go.mod @@ -0,0 +1,89 @@ +module repo-go + +go 1.21 + +require ( + github.com/pulumi/pulumi-awsx/sdk/v2 v2.2.0 + github.com/pulumi/pulumi/sdk/v3 v3.91.1 +) + +require ( + github.com/Microsoft/go-winio v0.5.2 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20221026131551-cf6655e29de4 // indirect + github.com/acomagu/bufpipe v1.0.3 // indirect + github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect + github.com/agext/levenshtein v1.2.3 // indirect + github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/atotto/clipboard v0.1.4 // indirect + github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect + github.com/blang/semver v3.5.1+incompatible // indirect + github.com/charmbracelet/bubbles v0.16.1 // indirect + github.com/charmbracelet/bubbletea v0.24.2 // indirect + github.com/charmbracelet/lipgloss v0.7.1 // indirect + github.com/cheggaaa/pb v1.0.29 // indirect + github.com/cloudflare/circl v1.3.3 // indirect + github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect + github.com/djherbis/times v1.5.0 // indirect + github.com/emirpasic/gods v1.18.1 // indirect + github.com/go-git/gcfg v1.5.0 // indirect + github.com/go-git/go-billy/v5 v5.4.0 // indirect + github.com/go-git/go-git/v5 v5.6.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/glog v1.1.0 // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/hashicorp/hcl/v2 v2.17.0 // indirect + github.com/imdario/mergo v0.3.13 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect + github.com/kevinburke/ssh_config v1.2.0 // indirect + github.com/lucasb-eyer/go-colorful v1.2.0 // indirect + github.com/mattn/go-isatty v0.0.18 // indirect + github.com/mattn/go-localereader v0.0.1 // indirect + github.com/mattn/go-runewidth v0.0.14 // indirect + github.com/mitchellh/go-ps v1.0.0 // indirect + github.com/mitchellh/go-wordwrap v1.0.1 // indirect + github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect + github.com/muesli/cancelreader v0.2.2 // indirect + github.com/muesli/reflow v0.3.0 // indirect + github.com/muesli/termenv v0.15.1 // indirect + github.com/opentracing/basictracer-go v1.1.0 // indirect + github.com/opentracing/opentracing-go v1.2.0 // indirect + github.com/pjbgf/sha1cd v0.3.0 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/pkg/term v1.1.0 // indirect + github.com/pulumi/esc v0.5.6 // indirect + github.com/pulumi/pulumi-aws/sdk/v6 v6.7.0 // indirect + github.com/pulumi/pulumi-docker/sdk/v4 v4.4.3 // indirect + github.com/rivo/uniseg v0.4.4 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect + github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect + github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect + github.com/sergi/go-diff v1.3.1 // indirect + github.com/skeema/knownhosts v1.1.0 // indirect + github.com/spf13/cobra v1.7.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/texttheater/golang-levenshtein v1.0.1 // indirect + github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 // indirect + github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect + github.com/uber/jaeger-lib v2.4.1+incompatible // indirect + github.com/xanzy/ssh-agent v0.3.3 // indirect + github.com/zclconf/go-cty v1.13.2 // indirect + go.uber.org/atomic v1.9.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sync v0.2.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/term v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d // indirect + google.golang.org/grpc v1.57.1 // indirect + google.golang.org/protobuf v1.31.0 // indirect + gopkg.in/warnings.v0 v0.1.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + lukechampine.com/frand v1.4.2 // indirect + sourcegraph.com/sourcegraph/appdash v0.0.0-20211028080628-e2786a622600 // indirect +) diff --git a/themes/default/static/examples/awsx-ecr-image-go/main.go b/themes/default/static/examples/awsx-ecr-image-go/main.go new file mode 100644 index 00000000000..180644a397e --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-go/main.go @@ -0,0 +1,29 @@ +package main + +import ( + "github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/ecr" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + repository, err := ecr.NewRepository(ctx, "repository", &ecr.RepositoryArgs{ + ForceDelete: pulumi.Bool(true), + }) + if err != nil { + return err + } + + _, err = ecr.NewImage(ctx, "image", &ecr.ImageArgs{ + RepositoryUrl: repository.Url, + Context: pulumi.String("./app"), + Platform: pulumi.String("linux/amd64"), + }) + if err != nil { + return err + } + + ctx.Export("url", repository.Url) + return nil + }) +} diff --git a/themes/default/static/examples/awsx-ecr-image-java/Pulumi.yaml b/themes/default/static/examples/awsx-ecr-image-java/Pulumi.yaml new file mode 100644 index 00000000000..664b91d33dd --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-java/Pulumi.yaml @@ -0,0 +1,3 @@ +name: awsx-ecr-image-java +runtime: java +description: A minimal AWS Java Pulumi program diff --git a/themes/default/static/examples/awsx-ecr-image-java/app/Dockerfile b/themes/default/static/examples/awsx-ecr-image-java/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-java/app/Dockerfile @@ -0,0 +1 @@ +FROM nginx \ No newline at end of file diff --git a/themes/default/static/examples/awsx-ecr-image-java/pom.xml b/themes/default/static/examples/awsx-ecr-image-java/pom.xml new file mode 100644 index 00000000000..e55f2b3f12f --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-java/pom.xml @@ -0,0 +1,97 @@ + + + 4.0.0 + + com.pulumi + awsx-ecr-image-java + 1.0-SNAPSHOT + + + UTF-8 + 11 + 11 + 11 + myproject.App + + + + + + com.pulumi + pulumi + (,1.0] + + + com.pulumi + aws + (6.0.2,6.99] + + + com.pulumi + awsx + (2.0.2,2.99] + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.2 + + + + true + ${mainClass} + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.3.0 + + + + true + ${mainClass} + + + + jar-with-dependencies + + + + + make-my-jar-with-dependencies + package + + single + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.0.0 + + ${mainClass} + ${mainArgs} + + + + org.apache.maven.plugins + maven-wrapper-plugin + 3.1.0 + + 3.8.5 + + + + + diff --git a/themes/default/static/examples/awsx-ecr-image-java/src/main/java/myproject/App.java b/themes/default/static/examples/awsx-ecr-image-java/src/main/java/myproject/App.java new file mode 100644 index 00000000000..05dbafa8db3 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-java/src/main/java/myproject/App.java @@ -0,0 +1,28 @@ +package myproject; + +import com.pulumi.Context; +import com.pulumi.Pulumi; +import com.pulumi.awsx.ecr.Repository; +import com.pulumi.awsx.ecr.RepositoryArgs; +import com.pulumi.awsx.ecr.Image; +import com.pulumi.awsx.ecr.ImageArgs; + +public class App { + public static void main(String[] args) { + Pulumi.run(App::stack); + } + + public static void stack(Context ctx) { + var repository = new Repository("repository", RepositoryArgs.builder() + .forceDelete(true) + .build()); + + var image = new Image("image", ImageArgs.builder() + .repositoryUrl(repository.url()) + .context("./app") + .platform("linux/amd64") + .build()); + + ctx.export("url", repository.url()); + } +} diff --git a/themes/default/static/examples/awsx-ecr-image-javascript/Pulumi.yaml b/themes/default/static/examples/awsx-ecr-image-javascript/Pulumi.yaml new file mode 100644 index 00000000000..06fa5efb89a --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-javascript/Pulumi.yaml @@ -0,0 +1,6 @@ +name: awsx-ecr-image-javascript +runtime: + name: nodejs + options: + typescript: false +description: A minimal AWS JavaScript Pulumi program diff --git a/themes/default/static/examples/awsx-ecr-image-javascript/app/Dockerfile b/themes/default/static/examples/awsx-ecr-image-javascript/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-javascript/app/Dockerfile @@ -0,0 +1 @@ +FROM nginx \ No newline at end of file diff --git a/themes/default/static/examples/awsx-ecr-image-javascript/index.js b/themes/default/static/examples/awsx-ecr-image-javascript/index.js new file mode 100644 index 00000000000..f8923e92a16 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-javascript/index.js @@ -0,0 +1,15 @@ +"use strict"; +const pulumi = require("@pulumi/pulumi"); +const awsx = require("@pulumi/awsx"); + +const repository = new awsx.ecr.Repository("repository", { + forceDelete: true, +}); + +const image = new awsx.ecr.Image("image", { + repositoryUrl: repository.url, + context: "./app", + platform: "linux/amd64", +}); + +exports.url = repository.url; diff --git a/themes/default/static/examples/awsx-ecr-image-javascript/package.json b/themes/default/static/examples/awsx-ecr-image-javascript/package.json new file mode 100644 index 00000000000..f1751a5ba3d --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-javascript/package.json @@ -0,0 +1,9 @@ +{ + "name": "awsx-ecr-image-javascript", + "main": "index.js", + "dependencies": { + "@pulumi/pulumi": "^3.0.0", + "@pulumi/aws": "^6.0.0", + "@pulumi/awsx": "^2.0.0" + } +} diff --git a/themes/default/static/examples/awsx-ecr-image-python/Pulumi.yaml b/themes/default/static/examples/awsx-ecr-image-python/Pulumi.yaml new file mode 100644 index 00000000000..d7857446902 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-python/Pulumi.yaml @@ -0,0 +1,6 @@ +name: awsx-ecr-image-python +runtime: + name: python + options: + virtualenv: venv +description: A minimal AWS Python Pulumi program diff --git a/themes/default/static/examples/awsx-ecr-image-python/__main__.py b/themes/default/static/examples/awsx-ecr-image-python/__main__.py new file mode 100644 index 00000000000..a418834a6b5 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-python/__main__.py @@ -0,0 +1,14 @@ +import pulumi +import pulumi_awsx as awsx + +repository = awsx.ecr.Repository("repository", awsx.ecr.RepositoryArgs( + force_delete=True, +)) + +image = awsx.ecr.Image("image", awsx.ecr.ImageArgs( + repository_url=repository.url, + context="./app", + platform="linux/amd64", +)) + +pulumi.export("url", repository.url) diff --git a/themes/default/static/examples/awsx-ecr-image-python/app/Dockerfile b/themes/default/static/examples/awsx-ecr-image-python/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-python/app/Dockerfile @@ -0,0 +1 @@ +FROM nginx \ No newline at end of file diff --git a/themes/default/static/examples/awsx-ecr-image-python/requirements.txt b/themes/default/static/examples/awsx-ecr-image-python/requirements.txt new file mode 100644 index 00000000000..c8097039a51 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-python/requirements.txt @@ -0,0 +1,3 @@ +pulumi>=3.0.0,<4.0.0 +pulumi-aws>=6.0.2,<7.0.0 +pulumi-awsx>=2.0.0,<3.0.0 diff --git a/themes/default/static/examples/awsx-ecr-image-typescript/Pulumi.yaml b/themes/default/static/examples/awsx-ecr-image-typescript/Pulumi.yaml new file mode 100644 index 00000000000..0315ca46fe6 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-typescript/Pulumi.yaml @@ -0,0 +1,3 @@ +name: awsx-ecr-image-typescript +runtime: nodejs +description: A minimal AWS TypeScript Pulumi program diff --git a/themes/default/static/examples/awsx-ecr-image-typescript/app/Dockerfile b/themes/default/static/examples/awsx-ecr-image-typescript/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-typescript/app/Dockerfile @@ -0,0 +1 @@ +FROM nginx \ No newline at end of file diff --git a/themes/default/static/examples/awsx-ecr-image-typescript/index.ts b/themes/default/static/examples/awsx-ecr-image-typescript/index.ts new file mode 100644 index 00000000000..0952dd7ee81 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-typescript/index.ts @@ -0,0 +1,14 @@ +import * as pulumi from "@pulumi/pulumi"; +import * as awsx from "@pulumi/awsx"; + +const repository = new awsx.ecr.Repository("repository", { + forceDelete: true, +}); + +const image = new awsx.ecr.Image("image", { + repositoryUrl: repository.url, + context: "./app", + platform: "linux/amd64", +}); + +export const url = repository.url; diff --git a/themes/default/static/examples/awsx-ecr-image-typescript/package.json b/themes/default/static/examples/awsx-ecr-image-typescript/package.json new file mode 100644 index 00000000000..c0eba2ff6f3 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-typescript/package.json @@ -0,0 +1,12 @@ +{ + "name": "repo-typescript", + "main": "index.ts", + "devDependencies": { + "@types/node": "^18" + }, + "dependencies": { + "@pulumi/pulumi": "^3.0.0", + "@pulumi/aws": "^6.0.0", + "@pulumi/awsx": "^2.0.0" + } +} diff --git a/themes/default/static/examples/awsx-ecr-image-typescript/tsconfig.json b/themes/default/static/examples/awsx-ecr-image-typescript/tsconfig.json new file mode 100644 index 00000000000..ab65afa6135 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-typescript/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "strict": true, + "outDir": "bin", + "target": "es2016", + "module": "commonjs", + "moduleResolution": "node", + "sourceMap": true, + "experimentalDecorators": true, + "pretty": true, + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.ts" + ] +} diff --git a/themes/default/static/examples/awsx-ecr-image-yaml/Pulumi.yaml b/themes/default/static/examples/awsx-ecr-image-yaml/Pulumi.yaml new file mode 100644 index 00000000000..5fb58ac031f --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-yaml/Pulumi.yaml @@ -0,0 +1,18 @@ +name: awsx-ecr-image-yaml +runtime: yaml + +resources: + repository: + type: awsx:ecr:Repository + properties: + forceDelete: true + +image: + type: awsx:ecr:Image + properties: + repositoryUrl: ${repository.url} + context: "./app" + platform: "linux/amd64" + +outputs: + url: ${repository.url} diff --git a/themes/default/static/examples/awsx-ecr-image-yaml/app/Dockerfile b/themes/default/static/examples/awsx-ecr-image-yaml/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/examples/awsx-ecr-image-yaml/app/Dockerfile @@ -0,0 +1 @@ +FROM nginx \ No newline at end of file diff --git a/themes/default/static/examples/awsx-vpc-fargate-service-csharp/Program.cs b/themes/default/static/examples/awsx-vpc-fargate-service-csharp/Program.cs new file mode 100644 index 00000000000..6f89035a729 --- /dev/null +++ b/themes/default/static/examples/awsx-vpc-fargate-service-csharp/Program.cs @@ -0,0 +1,59 @@ +using System.Collections.Generic; +using System.Linq; +using Pulumi; +using Aws = Pulumi.Aws; +using Awsx = Pulumi.Awsx; + +return await Deployment.RunAsync(() => +{ + var vpc = new Awsx.Ec2.Vpc("vpc"); + + var securityGroup = new Aws.Ec2.SecurityGroup("securityGroup", new() + { + VpcId = vpc.VpcId, + Egress = new[] + { + new Aws.Ec2.Inputs.SecurityGroupEgressArgs + { + FromPort = 0, + ToPort = 0, + Protocol = "-1", + CidrBlocks = new[] + { + "0.0.0.0/0", + }, + Ipv6CidrBlocks = new[] + { + "::/0", + }, + }, + }, + }); + + var cluster = new Aws.Ecs.Cluster("cluster"); + + var service = new Awsx.Ecs.FargateService("service", new() + { + Cluster = cluster.Arn, + NetworkConfiguration = new Aws.Ecs.Inputs.ServiceNetworkConfigurationArgs + { + Subnets = vpc.PrivateSubnetIds, + SecurityGroups = new[] + { + securityGroup.Id, + }, + }, + DesiredCount = 2, + TaskDefinitionArgs = new Awsx.Ecs.Inputs.FargateServiceTaskDefinitionArgs + { + Container = new Awsx.Ecs.Inputs.TaskDefinitionContainerDefinitionArgs + { + Name = "my-service", + Image = "nginx:latest", + Cpu = 128, + Memory = 512, + Essential = true, + }, + }, + }); +}); diff --git a/themes/default/static/examples/awsx-vpc-fargate-service-csharp/Pulumi.yaml b/themes/default/static/examples/awsx-vpc-fargate-service-csharp/Pulumi.yaml new file mode 100644 index 00000000000..e2f556b8018 --- /dev/null +++ b/themes/default/static/examples/awsx-vpc-fargate-service-csharp/Pulumi.yaml @@ -0,0 +1,3 @@ +name: awsx-vpc-fargate-service-csharp +runtime: dotnet +description: A minimal AWS Pulumi YAML program diff --git a/themes/default/static/examples/awsx-vpc-fargate-service-csharp/awsx-vpc-fargate-service-csharp.csproj b/themes/default/static/examples/awsx-vpc-fargate-service-csharp/awsx-vpc-fargate-service-csharp.csproj new file mode 100644 index 00000000000..57ad013e16d --- /dev/null +++ b/themes/default/static/examples/awsx-vpc-fargate-service-csharp/awsx-vpc-fargate-service-csharp.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + enable + + + + + + + + + diff --git a/themes/default/static/examples/awsx-vpc-fargate-service-go/Pulumi.yaml b/themes/default/static/examples/awsx-vpc-fargate-service-go/Pulumi.yaml new file mode 100644 index 00000000000..32a677705a5 --- /dev/null +++ b/themes/default/static/examples/awsx-vpc-fargate-service-go/Pulumi.yaml @@ -0,0 +1,3 @@ +name: awsx-vpc-fargate-service-go +runtime: go +description: A minimal AWS Pulumi YAML program diff --git a/themes/default/static/examples/awsx-vpc-fargate-service-go/go.mod b/themes/default/static/examples/awsx-vpc-fargate-service-go/go.mod new file mode 100644 index 00000000000..161501c8615 --- /dev/null +++ b/themes/default/static/examples/awsx-vpc-fargate-service-go/go.mod @@ -0,0 +1,95 @@ +module awsx-vpc-fargate-service-yaml + +go 1.21 + +toolchain go1.21.0 + +require ( + github.com/pulumi/pulumi-aws/sdk/v6 v6.10.0 + github.com/pulumi/pulumi-awsx/sdk/v2 v2.2.0 + github.com/pulumi/pulumi/sdk/v3 v3.93.0 +) + +require ( + dario.cat/mergo v1.0.0 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect + github.com/acomagu/bufpipe v1.0.4 // indirect + github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect + github.com/agext/levenshtein v1.2.3 // indirect + github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/atotto/clipboard v0.1.4 // indirect + github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect + github.com/blang/semver v3.5.1+incompatible // indirect + github.com/charmbracelet/bubbles v0.16.1 // indirect + github.com/charmbracelet/bubbletea v0.24.2 // indirect + github.com/charmbracelet/lipgloss v0.7.1 // indirect + github.com/cheggaaa/pb v1.0.29 // indirect + github.com/cloudflare/circl v1.3.3 // indirect + github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect + github.com/cyphar/filepath-securejoin v0.2.4 // indirect + github.com/djherbis/times v1.5.0 // indirect + github.com/emirpasic/gods v1.18.1 // indirect + github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect + github.com/go-git/go-billy/v5 v5.5.0 // indirect + github.com/go-git/go-git/v5 v5.9.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/glog v1.1.0 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/hashicorp/hcl/v2 v2.17.0 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect + github.com/kevinburke/ssh_config v1.2.0 // indirect + github.com/lucasb-eyer/go-colorful v1.2.0 // indirect + github.com/mattn/go-isatty v0.0.18 // indirect + github.com/mattn/go-localereader v0.0.1 // indirect + github.com/mattn/go-runewidth v0.0.14 // indirect + github.com/mitchellh/go-ps v1.0.0 // indirect + github.com/mitchellh/go-wordwrap v1.0.1 // indirect + github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect + github.com/muesli/cancelreader v0.2.2 // indirect + github.com/muesli/reflow v0.3.0 // indirect + github.com/muesli/termenv v0.15.1 // indirect + github.com/opentracing/basictracer-go v1.1.0 // indirect + github.com/opentracing/opentracing-go v1.2.0 // indirect + github.com/pjbgf/sha1cd v0.3.0 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/pkg/term v1.1.0 // indirect + github.com/pulumi/esc v0.5.6 // indirect + github.com/pulumi/pulumi-docker/sdk/v4 v4.4.3 // indirect + github.com/rivo/uniseg v0.4.4 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect + github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect + github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect + github.com/sergi/go-diff v1.3.1 // indirect + github.com/skeema/knownhosts v1.2.0 // indirect + github.com/spf13/cobra v1.7.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/texttheater/golang-levenshtein v1.0.1 // indirect + github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 // indirect + github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect + github.com/uber/jaeger-lib v2.4.1+incompatible // indirect + github.com/xanzy/ssh-agent v0.3.3 // indirect + github.com/zclconf/go-cty v1.13.2 // indirect + go.uber.org/atomic v1.9.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect + golang.org/x/mod v0.13.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sync v0.4.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/term v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect + golang.org/x/tools v0.14.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d // indirect + google.golang.org/grpc v1.57.1 // indirect + google.golang.org/protobuf v1.31.0 // indirect + gopkg.in/warnings.v0 v0.1.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + lukechampine.com/frand v1.4.2 // indirect + sourcegraph.com/sourcegraph/appdash v0.0.0-20211028080628-e2786a622600 // indirect +) diff --git a/themes/default/static/examples/awsx-vpc-fargate-service-go/main.go b/themes/default/static/examples/awsx-vpc-fargate-service-go/main.go new file mode 100644 index 00000000000..7f3b4cd3845 --- /dev/null +++ b/themes/default/static/examples/awsx-vpc-fargate-service-go/main.go @@ -0,0 +1,69 @@ +package main + +import ( + awsec2 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2" + "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ecs" + "github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/ec2" + awsxecs "github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/ecs" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + + vpc, err := ec2.NewVpc(ctx, "vpc", nil) + if err != nil { + return err + } + + securityGroup, err := awsec2.NewSecurityGroup(ctx, "securityGroup", &awsec2.SecurityGroupArgs{ + VpcId: vpc.VpcId, + Egress: awsec2.SecurityGroupEgressArray{ + &awsec2.SecurityGroupEgressArgs{ + FromPort: pulumi.Int(0), + ToPort: pulumi.Int(0), + Protocol: pulumi.String("-1"), + CidrBlocks: pulumi.StringArray{ + pulumi.String("0.0.0.0/0"), + }, + Ipv6CidrBlocks: pulumi.StringArray{ + pulumi.String("::/0"), + }, + }, + }, + }) + if err != nil { + return err + } + + cluster, err := ecs.NewCluster(ctx, "cluster", nil) + if err != nil { + return err + } + + _, err = awsxecs.NewFargateService(ctx, "service", &awsxecs.FargateServiceArgs{ + Cluster: cluster.Arn, + NetworkConfiguration: &ecs.ServiceNetworkConfigurationArgs{ + Subnets: vpc.PrivateSubnetIds, + SecurityGroups: pulumi.StringArray{ + securityGroup.ID(), + }, + }, + DesiredCount: pulumi.Int(2), + TaskDefinitionArgs: &awsxecs.FargateServiceTaskDefinitionArgs{ + Container: &awsxecs.TaskDefinitionContainerDefinitionArgs{ + Name: pulumi.String("my-service"), + Image: pulumi.String("nginx:latest"), + Cpu: pulumi.Int(128), + Memory: pulumi.Int(512), + Essential: pulumi.Bool(true), + }, + }, + }) + if err != nil { + return err + } + + return nil + }) +} diff --git a/themes/default/static/examples/awsx-vpc-fargate-service-java/Pulumi.yaml b/themes/default/static/examples/awsx-vpc-fargate-service-java/Pulumi.yaml new file mode 100644 index 00000000000..a8557c5fc38 --- /dev/null +++ b/themes/default/static/examples/awsx-vpc-fargate-service-java/Pulumi.yaml @@ -0,0 +1,3 @@ +name: awsx-vpc-fargate-service-java +runtime: java +description: A minimal AWS Pulumi YAML program diff --git a/themes/default/static/examples/awsx-vpc-fargate-service-java/pom.xml b/themes/default/static/examples/awsx-vpc-fargate-service-java/pom.xml new file mode 100644 index 00000000000..05a393f543d --- /dev/null +++ b/themes/default/static/examples/awsx-vpc-fargate-service-java/pom.xml @@ -0,0 +1,97 @@ + + + 4.0.0 + + com.pulumi + awsx-vpc-fargate-service-java + 1.0-SNAPSHOT + + + UTF-8 + 11 + 11 + 11 + myproject.App + + + + + + com.pulumi + pulumi + (,1.0] + + + com.pulumi + aws + (6.0.0,6.99] + + + com.pulumi + awsx + (2.0.0,2.99] + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.2 + + + + true + ${mainClass} + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.4.2 + + + + true + ${mainClass} + + + + jar-with-dependencies + + + + + make-my-jar-with-dependencies + package + + single + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.1.0 + + ${mainClass} + ${mainArgs} + + + + org.apache.maven.plugins + maven-wrapper-plugin + 3.1.1 + + 3.8.5 + + + + + diff --git a/themes/default/static/examples/awsx-vpc-fargate-service-java/src/main/java/myproject/App.java b/themes/default/static/examples/awsx-vpc-fargate-service-java/src/main/java/myproject/App.java new file mode 100644 index 00000000000..473dea7b7a1 --- /dev/null +++ b/themes/default/static/examples/awsx-vpc-fargate-service-java/src/main/java/myproject/App.java @@ -0,0 +1,46 @@ +package myproject; + +import com.pulumi.Context; +import com.pulumi.Pulumi; +import com.pulumi.core.Output; +import com.pulumi.awsx.ecr.Repository; +import com.pulumi.awsx.ecr.RepositoryArgs; +import com.pulumi.aws.ecs.Cluster; +import com.pulumi.awsx.lb.ApplicationLoadBalancer; +import com.pulumi.awsx.ecs.FargateService; +import com.pulumi.awsx.ecs.FargateServiceArgs; +import com.pulumi.awsx.ecs.inputs.FargateServiceTaskDefinitionArgs; +import com.pulumi.awsx.ecs.inputs.TaskDefinitionContainerDefinitionArgs; +import com.pulumi.awsx.ecs.inputs.TaskDefinitionPortMappingArgs; + +public class App { + public static void main(String[] args) { + Pulumi.run(App::stack); + } + + public static void stack(Context ctx) { + var cluster = new Cluster("cluster"); + + var lb = new ApplicationLoadBalancer("lb"); + + var service = new FargateService("service", FargateServiceArgs.builder() + .cluster(cluster.arn()) + .assignPublicIp(true) + .desiredCount(2) + .taskDefinitionArgs(FargateServiceTaskDefinitionArgs.builder() + .container(TaskDefinitionContainerDefinitionArgs.builder() + .name("my-service") + .image("nginx:latest") + .cpu(512) + .memory(128) + .essential(true) + .portMappings(TaskDefinitionPortMappingArgs.builder() + .targetGroup(lb.defaultTargetGroup()) + .build()) + .build()) + .build()) + .build()); + + ctx.export("url", lb.loadBalancer().applyValue(loadBalancer -> loadBalancer.dnsName())); + } +} diff --git a/themes/default/static/examples/awsx-vpc-fargate-service-javascript/Pulumi.yaml b/themes/default/static/examples/awsx-vpc-fargate-service-javascript/Pulumi.yaml new file mode 100644 index 00000000000..bda5a4adb05 --- /dev/null +++ b/themes/default/static/examples/awsx-vpc-fargate-service-javascript/Pulumi.yaml @@ -0,0 +1,6 @@ +name: awsx-vpc-fargate-service-javascript +runtime: + name: nodejs + options: + typescript: false +description: A minimal AWS Pulumi YAML program diff --git a/themes/default/static/examples/awsx-vpc-fargate-service-javascript/index.js b/themes/default/static/examples/awsx-vpc-fargate-service-javascript/index.js new file mode 100644 index 00000000000..ac576cd6db6 --- /dev/null +++ b/themes/default/static/examples/awsx-vpc-fargate-service-javascript/index.js @@ -0,0 +1,37 @@ +"use strict"; +const pulumi = require("@pulumi/pulumi"); +const aws = require("@pulumi/aws"); +const awsx = require("@pulumi/awsx"); + +const vpc = new awsx.ec2.Vpc("vpc"); + +const securityGroup = new aws.ec2.SecurityGroup("securityGroup", { + vpcId: vpc.vpcId, + egress: [{ + fromPort: 0, + toPort: 0, + protocol: "-1", + cidrBlocks: ["0.0.0.0/0"], + ipv6CidrBlocks: ["::/0"], + }], +}); + +const cluster = new aws.ecs.Cluster("cluster", {}); + +const service = new awsx.ecs.FargateService("service", { + cluster: cluster.arn, + networkConfiguration: { + subnets: vpc.privateSubnetIds, + securityGroups: [securityGroup.id], + }, + desiredCount: 2, + taskDefinitionArgs: { + container: { + name: "my-service", + image: "nginx:latest", + cpu: 128, + memory: 512, + essential: true, + }, + }, +}); diff --git a/themes/default/static/examples/awsx-vpc-fargate-service-javascript/package.json b/themes/default/static/examples/awsx-vpc-fargate-service-javascript/package.json new file mode 100644 index 00000000000..f5b9db80fd4 --- /dev/null +++ b/themes/default/static/examples/awsx-vpc-fargate-service-javascript/package.json @@ -0,0 +1,12 @@ +{ + "name": "awsx-vpc-fargate-service-javascript", + "devDependencies": { + "@types/node": "^14" + }, + "dependencies": { + "typescript": "^4.0.0", + "@pulumi/pulumi": "^3.0.0", + "@pulumi/aws": "^6.0.0", + "@pulumi/awsx": "^2.0.0" + } +} diff --git a/themes/default/static/examples/awsx-vpc-fargate-service-python/Pulumi.yaml b/themes/default/static/examples/awsx-vpc-fargate-service-python/Pulumi.yaml new file mode 100644 index 00000000000..68e8819a340 --- /dev/null +++ b/themes/default/static/examples/awsx-vpc-fargate-service-python/Pulumi.yaml @@ -0,0 +1,3 @@ +name: awsx-vpc-fargate-service-python +runtime: python +description: A minimal AWS Pulumi YAML program diff --git a/themes/default/static/examples/awsx-vpc-fargate-service-python/__main__.py b/themes/default/static/examples/awsx-vpc-fargate-service-python/__main__.py new file mode 100644 index 00000000000..d66d407586d --- /dev/null +++ b/themes/default/static/examples/awsx-vpc-fargate-service-python/__main__.py @@ -0,0 +1,39 @@ +import pulumi +import pulumi_aws as aws +import pulumi_awsx as awsx + +vpc = awsx.ec2.Vpc("vpc") + +security_group = aws.ec2.SecurityGroup( + "securityGroup", + vpc_id=vpc.vpc_id, + egress=[ + aws.ec2.SecurityGroupEgressArgs( + from_port=0, + to_port=0, + protocol="-1", + cidr_blocks=["0.0.0.0/0"], + ipv6_cidr_blocks=["::/0"], + ) + ], +) + +cluster = aws.ecs.Cluster("cluster") + +service = awsx.ecs.FargateService( + "service", + cluster=cluster.arn, + network_configuration=aws.ecs.ServiceNetworkConfigurationArgs( + subnets=vpc.private_subnet_ids, security_groups=[security_group.id] + ), + desired_count=2, + task_definition_args=awsx.ecs.FargateServiceTaskDefinitionArgs( + container=awsx.ecs.TaskDefinitionContainerDefinitionArgs( + name="my-service", + image="nginx:latest", + cpu=512, + memory=128, + essential=True, + ), + ), +) diff --git a/themes/default/static/examples/awsx-vpc-fargate-service-python/requirements.txt b/themes/default/static/examples/awsx-vpc-fargate-service-python/requirements.txt new file mode 100644 index 00000000000..961f30bc6eb --- /dev/null +++ b/themes/default/static/examples/awsx-vpc-fargate-service-python/requirements.txt @@ -0,0 +1,3 @@ +pulumi>=3.0.0,<4.0.0 +pulumi-aws>=6.0.0,<7.0.0 +pulumi-awsx>=2.0.0,<3.0.0 diff --git a/themes/default/static/examples/awsx-vpc-fargate-service-typescript/Pulumi.yaml b/themes/default/static/examples/awsx-vpc-fargate-service-typescript/Pulumi.yaml new file mode 100644 index 00000000000..105b2d8fbf2 --- /dev/null +++ b/themes/default/static/examples/awsx-vpc-fargate-service-typescript/Pulumi.yaml @@ -0,0 +1,3 @@ +name: awsx-vpc-fargate-service-typescript +runtime: nodejs +description: A minimal AWS Pulumi YAML program diff --git a/themes/default/static/examples/awsx-vpc-fargate-service-typescript/index.ts b/themes/default/static/examples/awsx-vpc-fargate-service-typescript/index.ts new file mode 100644 index 00000000000..03e118c45ce --- /dev/null +++ b/themes/default/static/examples/awsx-vpc-fargate-service-typescript/index.ts @@ -0,0 +1,36 @@ +import * as pulumi from "@pulumi/pulumi"; +import * as aws from "@pulumi/aws"; +import * as awsx from "@pulumi/awsx"; + +const vpc = new awsx.ec2.Vpc("vpc"); + +const securityGroup = new aws.ec2.SecurityGroup("securityGroup", { + vpcId: vpc.vpcId, + egress: [{ + fromPort: 0, + toPort: 0, + protocol: "-1", + cidrBlocks: ["0.0.0.0/0"], + ipv6CidrBlocks: ["::/0"], + }], +}); + +const cluster = new aws.ecs.Cluster("cluster", {}); + +const service = new awsx.ecs.FargateService("service", { + cluster: cluster.arn, + networkConfiguration: { + subnets: vpc.privateSubnetIds, + securityGroups: [securityGroup.id], + }, + desiredCount: 2, + taskDefinitionArgs: { + container: { + name: "my-service", + image: "nginx:latest", + cpu: 128, + memory: 512, + essential: true, + }, + }, +}); diff --git a/themes/default/static/examples/awsx-vpc-fargate-service-typescript/package.json b/themes/default/static/examples/awsx-vpc-fargate-service-typescript/package.json new file mode 100644 index 00000000000..f2cdb537458 --- /dev/null +++ b/themes/default/static/examples/awsx-vpc-fargate-service-typescript/package.json @@ -0,0 +1,12 @@ +{ + "name": "awsx-vpc-fargate-service-typescript", + "devDependencies": { + "@types/node": "^14" + }, + "dependencies": { + "typescript": "^4.0.0", + "@pulumi/pulumi": "^3.0.0", + "@pulumi/aws": "^6.0.0", + "@pulumi/awsx": "^2.0.0" + } +} diff --git a/themes/default/static/examples/awsx-vpc-fargate-service-typescript/tsconfig.json b/themes/default/static/examples/awsx-vpc-fargate-service-typescript/tsconfig.json new file mode 100644 index 00000000000..11fc69af240 --- /dev/null +++ b/themes/default/static/examples/awsx-vpc-fargate-service-typescript/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "strict": true, + "outDir": "bin", + "target": "es2016", + "module": "commonjs", + "moduleResolution": "node", + "sourceMap": true, + "experimentalDecorators": true, + "pretty": true, + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.ts", + ] +} \ No newline at end of file diff --git a/themes/default/static/examples/awsx-vpc-fargate-service-yaml/Pulumi.yaml b/themes/default/static/examples/awsx-vpc-fargate-service-yaml/Pulumi.yaml new file mode 100644 index 00000000000..8f6c7efbc93 --- /dev/null +++ b/themes/default/static/examples/awsx-vpc-fargate-service-yaml/Pulumi.yaml @@ -0,0 +1,36 @@ +name: awsx-vpc-fargate-service-yaml +runtime: yaml +description: A minimal AWS Pulumi YAML program +resources: + vpc: + type: awsx:ec2:Vpc + securityGroup: + type: aws:ec2:SecurityGroup + properties: + vpcId: ${vpc.vpcId} + egress: + - fromPort: 0 + toPort: 0 + protocol: -1 + cidrBlocks: + - 0.0.0.0/0 + ipv6CidrBlocks: + - "::/0" + cluster: + type: aws:ecs:Cluster + service: + type: awsx:ecs:FargateService + properties: + cluster: ${cluster.arn} + networkConfiguration: + subnets: ${vpc.privateSubnetIds} + securityGroups: + - ${securityGroup.id} + desiredCount: 2 + taskDefinitionArgs: + container: + name: my-service + image: nginx:latest + cpu: 128 + memory: 512 + essential: true diff --git a/themes/default/static/examples/load-balanced-fargate-ecr-csharp/Program.cs b/themes/default/static/examples/load-balanced-fargate-ecr-csharp/Program.cs new file mode 100644 index 00000000000..fb4ef9fd106 --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-ecr-csharp/Program.cs @@ -0,0 +1,53 @@ +using System.Collections.Generic; +using Pulumi; +using Aws = Pulumi.Aws; +using Awsx = Pulumi.Awsx; + +return await Deployment.RunAsync(() => +{ + var cluster = new Aws.Ecs.Cluster("cluster"); + + var repo = new Awsx.Ecr.Repository("repo", new() + { + ForceDelete = true, + }); + + var image = new Awsx.Ecr.Image("image", new() + { + RepositoryUrl = repo.Url, + Context = "./app", + Platform = "linux/amd64", + }); + + var lb = new Awsx.Lb.ApplicationLoadBalancer("lb"); + + var service = new Awsx.Ecs.FargateService("service", new Awsx.Ecs.FargateServiceArgs + { + Cluster = cluster.Arn, + AssignPublicIp = true, + TaskDefinitionArgs = new Awsx.Ecs.Inputs.FargateServiceTaskDefinitionArgs + { + Container = new Awsx.Ecs.Inputs.TaskDefinitionContainerDefinitionArgs + { + Name = "my-service", + Image = image.ImageUri, + Cpu = 128, + Memory = 512, + Essential = true, + PortMappings = new[] + { + new Awsx.Ecs.Inputs.TaskDefinitionPortMappingArgs + { + ContainerPort = 80, + TargetGroup = lb.DefaultTargetGroup, + }, + }, + }, + }, + }); + + return new Dictionary + { + ["url"] = lb.LoadBalancer.Apply(loadBalancer => Output.Format($"http://{loadBalancer.DnsName}")), + }; +}); diff --git a/themes/default/static/examples/load-balanced-fargate-ecr-csharp/Pulumi.yaml b/themes/default/static/examples/load-balanced-fargate-ecr-csharp/Pulumi.yaml new file mode 100644 index 00000000000..f4318892a7f --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-ecr-csharp/Pulumi.yaml @@ -0,0 +1,2 @@ +name: load-balanced-fargate-ecr-csharp +runtime: dotnet diff --git a/themes/default/static/examples/load-balanced-fargate-ecr-csharp/load-balanced-fargate-ecr-csharp.csproj b/themes/default/static/examples/load-balanced-fargate-ecr-csharp/load-balanced-fargate-ecr-csharp.csproj new file mode 100644 index 00000000000..57ad013e16d --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-ecr-csharp/load-balanced-fargate-ecr-csharp.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + enable + + + + + + + + + diff --git a/themes/default/static/examples/load-balanced-fargate-ecr-go/Pulumi.yaml b/themes/default/static/examples/load-balanced-fargate-ecr-go/Pulumi.yaml new file mode 100644 index 00000000000..50a872d5445 --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-ecr-go/Pulumi.yaml @@ -0,0 +1,3 @@ +name: load-balanced-fargate-ecr-go +runtime: go +description: A minimal AWS Pulumi YAML program diff --git a/themes/default/static/examples/load-balanced-fargate-ecr-go/go.mod b/themes/default/static/examples/load-balanced-fargate-ecr-go/go.mod new file mode 100644 index 00000000000..0dcfcbb5e7c --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-ecr-go/go.mod @@ -0,0 +1,95 @@ +module load-balanced-fargate-nginx-go + +go 1.21 + +toolchain go1.21.0 + +require ( + github.com/pulumi/pulumi-aws/sdk/v6 v6.10.0 + github.com/pulumi/pulumi-awsx/sdk/v2 v2.2.0 + github.com/pulumi/pulumi/sdk/v3 v3.93.0 +) + +require ( + dario.cat/mergo v1.0.0 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect + github.com/acomagu/bufpipe v1.0.4 // indirect + github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect + github.com/agext/levenshtein v1.2.3 // indirect + github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/atotto/clipboard v0.1.4 // indirect + github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect + github.com/blang/semver v3.5.1+incompatible // indirect + github.com/charmbracelet/bubbles v0.16.1 // indirect + github.com/charmbracelet/bubbletea v0.24.2 // indirect + github.com/charmbracelet/lipgloss v0.7.1 // indirect + github.com/cheggaaa/pb v1.0.29 // indirect + github.com/cloudflare/circl v1.3.3 // indirect + github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect + github.com/cyphar/filepath-securejoin v0.2.4 // indirect + github.com/djherbis/times v1.5.0 // indirect + github.com/emirpasic/gods v1.18.1 // indirect + github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect + github.com/go-git/go-billy/v5 v5.5.0 // indirect + github.com/go-git/go-git/v5 v5.9.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/glog v1.1.0 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/hashicorp/hcl/v2 v2.17.0 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect + github.com/kevinburke/ssh_config v1.2.0 // indirect + github.com/lucasb-eyer/go-colorful v1.2.0 // indirect + github.com/mattn/go-isatty v0.0.18 // indirect + github.com/mattn/go-localereader v0.0.1 // indirect + github.com/mattn/go-runewidth v0.0.14 // indirect + github.com/mitchellh/go-ps v1.0.0 // indirect + github.com/mitchellh/go-wordwrap v1.0.1 // indirect + github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect + github.com/muesli/cancelreader v0.2.2 // indirect + github.com/muesli/reflow v0.3.0 // indirect + github.com/muesli/termenv v0.15.1 // indirect + github.com/opentracing/basictracer-go v1.1.0 // indirect + github.com/opentracing/opentracing-go v1.2.0 // indirect + github.com/pjbgf/sha1cd v0.3.0 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/pkg/term v1.1.0 // indirect + github.com/pulumi/esc v0.5.6 // indirect + github.com/pulumi/pulumi-docker/sdk/v4 v4.4.3 // indirect + github.com/rivo/uniseg v0.4.4 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect + github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect + github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect + github.com/sergi/go-diff v1.3.1 // indirect + github.com/skeema/knownhosts v1.2.0 // indirect + github.com/spf13/cobra v1.7.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/texttheater/golang-levenshtein v1.0.1 // indirect + github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 // indirect + github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect + github.com/uber/jaeger-lib v2.4.1+incompatible // indirect + github.com/xanzy/ssh-agent v0.3.3 // indirect + github.com/zclconf/go-cty v1.13.2 // indirect + go.uber.org/atomic v1.9.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect + golang.org/x/mod v0.13.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sync v0.4.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/term v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect + golang.org/x/tools v0.14.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d // indirect + google.golang.org/grpc v1.57.1 // indirect + google.golang.org/protobuf v1.31.0 // indirect + gopkg.in/warnings.v0 v0.1.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + lukechampine.com/frand v1.4.2 // indirect + sourcegraph.com/sourcegraph/appdash v0.0.0-20211028080628-e2786a622600 // indirect +) diff --git a/themes/default/static/examples/load-balanced-fargate-ecr-go/main.go b/themes/default/static/examples/load-balanced-fargate-ecr-go/main.go new file mode 100644 index 00000000000..759e1f872d7 --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-ecr-go/main.go @@ -0,0 +1,65 @@ +package main + +import ( + "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ecs" + "github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/ecr" + ecsx "github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/ecs" + "github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/lb" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + repository, err := ecr.NewRepository(ctx, "repository", &ecr.RepositoryArgs{ + ForceDelete: pulumi.Bool(true), + }) + if err != nil { + return err + } + + image, err := ecr.NewImage(ctx, "image", &ecr.ImageArgs{ + RepositoryUrl: repository.Url, + Context: pulumi.String("./app"), + Platform: pulumi.StringPtr("linux/amd64"), + }) + if err != nil { + return err + } + + 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 = ecsx.NewFargateService(ctx, "service", &ecsx.FargateServiceArgs{ + Cluster: cluster.Arn, + AssignPublicIp: pulumi.Bool(true), + TaskDefinitionArgs: &ecsx.FargateServiceTaskDefinitionArgs{ + Container: &ecsx.TaskDefinitionContainerDefinitionArgs{ + Name: pulumi.String("app"), + Image: image.ImageUri, + Cpu: pulumi.Int(512), + Memory: pulumi.Int(128), + Essential: pulumi.Bool(true), + PortMappings: ecsx.TaskDefinitionPortMappingArray{ + &ecsx.TaskDefinitionPortMappingArgs{ + ContainerPort: pulumi.Int(80), + TargetGroup: lb.DefaultTargetGroup, + }, + }, + }, + }, + }) + if err != nil { + return err + } + + ctx.Export("url", pulumi.Sprintf("http://%s", lb.LoadBalancer.DnsName())) + return nil + }) +} diff --git a/themes/default/static/examples/load-balanced-fargate-ecr-java/Pulumi.yaml b/themes/default/static/examples/load-balanced-fargate-ecr-java/Pulumi.yaml new file mode 100644 index 00000000000..172461f5d31 --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-ecr-java/Pulumi.yaml @@ -0,0 +1,3 @@ +name: load-balanced-fargate-ecr-yaml +runtime: java +description: A minimal AWS Pulumi YAML program diff --git a/themes/default/static/examples/load-balanced-fargate-ecr-java/pom.xml b/themes/default/static/examples/load-balanced-fargate-ecr-java/pom.xml new file mode 100644 index 00000000000..ee6b7bc89c1 --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-ecr-java/pom.xml @@ -0,0 +1,97 @@ + + + 4.0.0 + + com.pulumi + load-balanced-fargate-ecr-java + 1.0-SNAPSHOT + + + UTF-8 + 11 + 11 + 11 + myproject.App + + + + + + com.pulumi + pulumi + (,1.0] + + + com.pulumi + aws + (6.0.0,6.99] + + + com.pulumi + awsx + (2.0.0,2.99] + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.2 + + + + true + ${mainClass} + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.4.2 + + + + true + ${mainClass} + + + + jar-with-dependencies + + + + + make-my-jar-with-dependencies + package + + single + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.1.0 + + ${mainClass} + ${mainArgs} + + + + org.apache.maven.plugins + maven-wrapper-plugin + 3.1.1 + + 3.8.5 + + + + + diff --git a/themes/default/static/examples/load-balanced-fargate-ecr-java/src/main/java/myproject/App.java b/themes/default/static/examples/load-balanced-fargate-ecr-java/src/main/java/myproject/App.java new file mode 100644 index 00000000000..7c6007b2ed7 --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-ecr-java/src/main/java/myproject/App.java @@ -0,0 +1,58 @@ +package myproject; + +import com.pulumi.Context; +import com.pulumi.Pulumi; +import com.pulumi.core.Output; +import com.pulumi.awsx.ecr.Repository; +import com.pulumi.awsx.ecr.RepositoryArgs; +import com.pulumi.awsx.ecr.Image; +import com.pulumi.awsx.ecr.ImageArgs; +import com.pulumi.aws.ecs.Cluster; +import com.pulumi.awsx.lb.ApplicationLoadBalancer; +import com.pulumi.awsx.ecs.FargateService; +import com.pulumi.awsx.ecs.FargateServiceArgs; +import com.pulumi.awsx.ecs.inputs.FargateServiceTaskDefinitionArgs; +import com.pulumi.awsx.ecs.inputs.TaskDefinitionContainerDefinitionArgs; +import com.pulumi.awsx.ecs.inputs.TaskDefinitionPortMappingArgs; + +public class App { + public static void main(String[] args) { + Pulumi.run(App::stack); + } + + public static void stack(Context ctx) { + var repository = new Repository("repository", RepositoryArgs.builder() + .forceDelete(true) + .build()); + + var image = new Image("image", ImageArgs.builder() + .repositoryUrl(repository.url()) + .context("./app") + .platform("linux/amd64") + .build()); + + var cluster = new Cluster("cluster"); + + var lb = new ApplicationLoadBalancer("lb"); + + var service = new FargateService("service", FargateServiceArgs.builder() + .cluster(cluster.arn()) + .assignPublicIp(true) + .taskDefinitionArgs(FargateServiceTaskDefinitionArgs.builder() + .container(TaskDefinitionContainerDefinitionArgs.builder() + .name("my-service") + .image(image.imageUri()) + .cpu(128) + .memory(512) + .essential(true) + .portMappings(TaskDefinitionPortMappingArgs.builder() + .containerPort(80) + .targetGroup(lb.defaultTargetGroup()) + .build()) + .build()) + .build()) + .build()); + + ctx.export("url", Output.format("http://%s", lb.loadBalancer().applyValue(loadBalancer -> loadBalancer.dnsName()))); + } +} diff --git a/themes/default/static/examples/load-balanced-fargate-ecr-javascript/Pulumi.yaml b/themes/default/static/examples/load-balanced-fargate-ecr-javascript/Pulumi.yaml new file mode 100644 index 00000000000..8d5db03a886 --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-ecr-javascript/Pulumi.yaml @@ -0,0 +1,6 @@ +name: load-balanced-fargate-ecr-javascript +runtime: + name: nodejs + options: + typescript: false +description: A minimal AWS Pulumi YAML program diff --git a/themes/default/static/examples/load-balanced-fargate-ecr-javascript/index.js b/themes/default/static/examples/load-balanced-fargate-ecr-javascript/index.js new file mode 100644 index 00000000000..6b97d55962a --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-ecr-javascript/index.js @@ -0,0 +1,38 @@ +"use strict"; +const pulumi = require("@pulumi/pulumi"); +const aws = require("@pulumi/aws"); +const awsx = require("@pulumi/awsx"); + +const repo = new awsx.ecr.Repository("repo", { + forceDelete: true, +}); + +const image = new awsx.ecr.Image("image", { + repositoryUrl: repo.url, + context: "./app", + platform: "linux/amd64", +}); + +const cluster = new aws.ecs.Cluster("cluster"); + +const lb = new awsx.lb.ApplicationLoadBalancer("lb"); + +const service = new awsx.ecs.FargateService("service", { + cluster: cluster.arn, + assignPublicIp: true, + taskDefinitionArgs: { + container: { + name: "my-service", + image: image.imageUri, + cpu: 128, + memory: 512, + essential: true, + portMappings: [{ + containerPort: 80, + targetGroup: lb.defaultTargetGroup, + }], + }, + }, +}); + +exports.url = pulumi.interpolate`http://${lb.loadBalancer.dnsName}`; diff --git a/themes/default/static/examples/load-balanced-fargate-ecr-javascript/package.json b/themes/default/static/examples/load-balanced-fargate-ecr-javascript/package.json new file mode 100644 index 00000000000..873e6353da2 --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-ecr-javascript/package.json @@ -0,0 +1,12 @@ +{ + "name": "load-balanced-fargate-ecr-javascript", + "devDependencies": { + "@types/node": "^14" + }, + "dependencies": { + "typescript": "^4.0.0", + "@pulumi/pulumi": "^3.0.0", + "@pulumi/aws": "^6.0.0", + "@pulumi/awsx": "^2.0.0" + } +} diff --git a/themes/default/static/examples/load-balanced-fargate-ecr-python/Pulumi.yaml b/themes/default/static/examples/load-balanced-fargate-ecr-python/Pulumi.yaml new file mode 100644 index 00000000000..e11e9c0462b --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-ecr-python/Pulumi.yaml @@ -0,0 +1,3 @@ +name: load-balanced-fargate-ecr-python +runtime: python +description: A minimal AWS Pulumi YAML program diff --git a/themes/default/static/examples/load-balanced-fargate-ecr-python/__main__.py b/themes/default/static/examples/load-balanced-fargate-ecr-python/__main__.py new file mode 100644 index 00000000000..1d887b457ad --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-ecr-python/__main__.py @@ -0,0 +1,45 @@ +import pulumi +import pulumi_aws as aws +import pulumi_awsx as awsx + +repository = awsx.ecr.Repository( + "repository", + awsx.ecr.RepositoryArgs( + force_delete=True + ), +) + +image = awsx.ecr.Image( + "image", + awsx.ecr.ImageArgs( + repository_url=repository.url, context="./app", platform="linux/amd64" + ), +) + +cluster = aws.ecs.Cluster("cluster") +lb = awsx.lb.ApplicationLoadBalancer("lb") + +service = awsx.ecs.FargateService( + "service", + awsx.ecs.FargateServiceArgs( + cluster=cluster.arn, + assign_public_ip=True, + task_definition_args=awsx.ecs.FargateServiceTaskDefinitionArgs( + container=awsx.ecs.TaskDefinitionContainerDefinitionArgs( + name="my-service", + image=image.image_uri, + cpu=512, + memory=128, + essential=True, + port_mappings=[ + awsx.ecs.TaskDefinitionPortMappingArgs( + container_port=80, + target_group=lb.default_target_group, + ) + ], + ), + ), + ), +) + +pulumi.export("url", pulumi.Output.concat("http://", lb.load_balancer.dns_name)) diff --git a/themes/default/static/examples/load-balanced-fargate-ecr-python/requirements.txt b/themes/default/static/examples/load-balanced-fargate-ecr-python/requirements.txt new file mode 100644 index 00000000000..961f30bc6eb --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-ecr-python/requirements.txt @@ -0,0 +1,3 @@ +pulumi>=3.0.0,<4.0.0 +pulumi-aws>=6.0.0,<7.0.0 +pulumi-awsx>=2.0.0,<3.0.0 diff --git a/themes/default/static/examples/load-balanced-fargate-ecr-typescript/Pulumi.yaml b/themes/default/static/examples/load-balanced-fargate-ecr-typescript/Pulumi.yaml new file mode 100644 index 00000000000..b759025fb8c --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-ecr-typescript/Pulumi.yaml @@ -0,0 +1,3 @@ +name: load-balanced-fargate-ecr-typescript +runtime: nodejs +description: A minimal AWS Pulumi YAML program diff --git a/themes/default/static/examples/load-balanced-fargate-ecr-typescript/index.ts b/themes/default/static/examples/load-balanced-fargate-ecr-typescript/index.ts new file mode 100644 index 00000000000..042b399d76b --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-ecr-typescript/index.ts @@ -0,0 +1,37 @@ +import * as pulumi from "@pulumi/pulumi"; +import * as aws from "@pulumi/aws"; +import * as awsx from "@pulumi/awsx"; + +const repo = new awsx.ecr.Repository("repo", { + forceDelete: true, +}); + +const image = new awsx.ecr.Image("image", { + repositoryUrl: repo.url, + context: "./app", + platform: "linux/amd64", +}); + +const cluster = new aws.ecs.Cluster("cluster"); + +const lb = new awsx.lb.ApplicationLoadBalancer("lb"); + +const service = new awsx.ecs.FargateService("service", { + cluster: cluster.arn, + assignPublicIp: true, + taskDefinitionArgs: { + container: { + name: "my-service", + image: image.imageUri, + cpu: 128, + memory: 512, + essential: true, + portMappings: [{ + containerPort: 80, + targetGroup: lb.defaultTargetGroup, + }], + }, + }, +}); + +export const url = pulumi.interpolate`http://${lb.loadBalancer.dnsName}`; diff --git a/themes/default/static/examples/load-balanced-fargate-ecr-typescript/package.json b/themes/default/static/examples/load-balanced-fargate-ecr-typescript/package.json new file mode 100644 index 00000000000..dbe7346ca8c --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-ecr-typescript/package.json @@ -0,0 +1,12 @@ +{ + "name": "load-balanced-fargate-ecr-typescript", + "devDependencies": { + "@types/node": "^14" + }, + "dependencies": { + "typescript": "^4.0.0", + "@pulumi/pulumi": "^3.0.0", + "@pulumi/aws": "^6.0.0", + "@pulumi/awsx": "^2.0.0" + } +} diff --git a/themes/default/static/examples/load-balanced-fargate-ecr-typescript/tsconfig.json b/themes/default/static/examples/load-balanced-fargate-ecr-typescript/tsconfig.json new file mode 100644 index 00000000000..11fc69af240 --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-ecr-typescript/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "strict": true, + "outDir": "bin", + "target": "es2016", + "module": "commonjs", + "moduleResolution": "node", + "sourceMap": true, + "experimentalDecorators": true, + "pretty": true, + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.ts", + ] +} \ No newline at end of file diff --git a/themes/default/static/examples/load-balanced-fargate-ecr-yaml/Pulumi.yaml b/themes/default/static/examples/load-balanced-fargate-ecr-yaml/Pulumi.yaml new file mode 100644 index 00000000000..c1c74215ffd --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-ecr-yaml/Pulumi.yaml @@ -0,0 +1,40 @@ +name: load-balanced-fargate-ecr-yaml +runtime: yaml + +resources: + repo: + type: awsx:ecr:Repository + properties: + forceDelete: true + + lb: + type: awsx:lb:ApplicationLoadBalancer + + image: + type: awsx:ecr:Image + properties: + repositoryUrl: ${repo.url} + context: ./app + platform: linux/amd64 + + cluster: + type: aws:ecs:Cluster + + service: + type: awsx:ecs:FargateService + properties: + cluster: ${cluster.arn} + assignPublicIp: true + taskDefinitionArgs: + container: + name: my-service + image: ${image.imageUri} + cpu: 128 + memory: 512 + essential: true + portMappings: + - containerPort: 80 + targetGroup: ${lb.defaultTargetGroup} + +outputs: + url: http://${lb.loadBalancer.dnsName} diff --git a/themes/default/static/examples/load-balanced-fargate-nginx-csharp/Program.cs b/themes/default/static/examples/load-balanced-fargate-nginx-csharp/Program.cs new file mode 100644 index 00000000000..984e2ad89b2 --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-nginx-csharp/Program.cs @@ -0,0 +1,45 @@ +using System.Collections.Generic; +using Pulumi; +using Aws = Pulumi.Aws; +using Awsx = Pulumi.Awsx; + +return await Deployment.RunAsync(() => +{ + var repo = new Awsx.Ecr.Repository("repo", new() + { + ForceDelete = true, + }); + + var lb = new Awsx.Lb.ApplicationLoadBalancer("lb"); + var cluster = new Aws.Ecs.Cluster("cluster"); + + var service = new Awsx.Ecs.FargateService("service", new() + { + Cluster = cluster.Arn, + AssignPublicIp = true, + TaskDefinitionArgs = new Awsx.Ecs.Inputs.FargateServiceTaskDefinitionArgs + { + Container = new Awsx.Ecs.Inputs.TaskDefinitionContainerDefinitionArgs + { + Name = "my-service", + Image = "nginx:latest", + Cpu = 128, + Memory = 512, + Essential = true, + PortMappings = new() + { + new Awsx.Ecs.Inputs.TaskDefinitionPortMappingArgs + { + ContainerPort = 80, + TargetGroup = lb.DefaultTargetGroup, + }, + }, + }, + }, + }); + + return new Dictionary + { + ["url"] = lb.LoadBalancer.Apply(loadBalancer => Output.Format($"http://{loadBalancer.DnsName}")), + }; +}); diff --git a/themes/default/static/examples/load-balanced-fargate-nginx-csharp/Pulumi.yaml b/themes/default/static/examples/load-balanced-fargate-nginx-csharp/Pulumi.yaml new file mode 100644 index 00000000000..32c70ae9b6e --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-nginx-csharp/Pulumi.yaml @@ -0,0 +1,2 @@ +name: load-balanced-fargate-nginx-csharp +runtime: dotnet diff --git a/themes/default/static/examples/load-balanced-fargate-nginx-csharp/load-balanced-fargate-nginx-csharp.csproj b/themes/default/static/examples/load-balanced-fargate-nginx-csharp/load-balanced-fargate-nginx-csharp.csproj new file mode 100644 index 00000000000..57ad013e16d --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-nginx-csharp/load-balanced-fargate-nginx-csharp.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + enable + + + + + + + + + diff --git a/themes/default/static/examples/load-balanced-fargate-nginx-go/Pulumi.yaml b/themes/default/static/examples/load-balanced-fargate-nginx-go/Pulumi.yaml new file mode 100644 index 00000000000..4c28491919b --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-nginx-go/Pulumi.yaml @@ -0,0 +1,3 @@ +name: load-balanced-fargate-nginx-go +runtime: go +description: A minimal AWS Pulumi YAML program diff --git a/themes/default/static/examples/load-balanced-fargate-nginx-go/go.mod b/themes/default/static/examples/load-balanced-fargate-nginx-go/go.mod new file mode 100644 index 00000000000..0dcfcbb5e7c --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-nginx-go/go.mod @@ -0,0 +1,95 @@ +module load-balanced-fargate-nginx-go + +go 1.21 + +toolchain go1.21.0 + +require ( + github.com/pulumi/pulumi-aws/sdk/v6 v6.10.0 + github.com/pulumi/pulumi-awsx/sdk/v2 v2.2.0 + github.com/pulumi/pulumi/sdk/v3 v3.93.0 +) + +require ( + dario.cat/mergo v1.0.0 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect + github.com/acomagu/bufpipe v1.0.4 // indirect + github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect + github.com/agext/levenshtein v1.2.3 // indirect + github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/atotto/clipboard v0.1.4 // indirect + github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect + github.com/blang/semver v3.5.1+incompatible // indirect + github.com/charmbracelet/bubbles v0.16.1 // indirect + github.com/charmbracelet/bubbletea v0.24.2 // indirect + github.com/charmbracelet/lipgloss v0.7.1 // indirect + github.com/cheggaaa/pb v1.0.29 // indirect + github.com/cloudflare/circl v1.3.3 // indirect + github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect + github.com/cyphar/filepath-securejoin v0.2.4 // indirect + github.com/djherbis/times v1.5.0 // indirect + github.com/emirpasic/gods v1.18.1 // indirect + github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect + github.com/go-git/go-billy/v5 v5.5.0 // indirect + github.com/go-git/go-git/v5 v5.9.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/glog v1.1.0 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/hashicorp/hcl/v2 v2.17.0 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect + github.com/kevinburke/ssh_config v1.2.0 // indirect + github.com/lucasb-eyer/go-colorful v1.2.0 // indirect + github.com/mattn/go-isatty v0.0.18 // indirect + github.com/mattn/go-localereader v0.0.1 // indirect + github.com/mattn/go-runewidth v0.0.14 // indirect + github.com/mitchellh/go-ps v1.0.0 // indirect + github.com/mitchellh/go-wordwrap v1.0.1 // indirect + github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect + github.com/muesli/cancelreader v0.2.2 // indirect + github.com/muesli/reflow v0.3.0 // indirect + github.com/muesli/termenv v0.15.1 // indirect + github.com/opentracing/basictracer-go v1.1.0 // indirect + github.com/opentracing/opentracing-go v1.2.0 // indirect + github.com/pjbgf/sha1cd v0.3.0 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/pkg/term v1.1.0 // indirect + github.com/pulumi/esc v0.5.6 // indirect + github.com/pulumi/pulumi-docker/sdk/v4 v4.4.3 // indirect + github.com/rivo/uniseg v0.4.4 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect + github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect + github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect + github.com/sergi/go-diff v1.3.1 // indirect + github.com/skeema/knownhosts v1.2.0 // indirect + github.com/spf13/cobra v1.7.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/texttheater/golang-levenshtein v1.0.1 // indirect + github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 // indirect + github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect + github.com/uber/jaeger-lib v2.4.1+incompatible // indirect + github.com/xanzy/ssh-agent v0.3.3 // indirect + github.com/zclconf/go-cty v1.13.2 // indirect + go.uber.org/atomic v1.9.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect + golang.org/x/mod v0.13.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sync v0.4.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/term v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect + golang.org/x/tools v0.14.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d // indirect + google.golang.org/grpc v1.57.1 // indirect + google.golang.org/protobuf v1.31.0 // indirect + gopkg.in/warnings.v0 v0.1.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + lukechampine.com/frand v1.4.2 // indirect + sourcegraph.com/sourcegraph/appdash v0.0.0-20211028080628-e2786a622600 // indirect +) diff --git a/themes/default/static/examples/load-balanced-fargate-nginx-go/main.go b/themes/default/static/examples/load-balanced-fargate-nginx-go/main.go new file mode 100644 index 00000000000..923189b542d --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-nginx-go/main.go @@ -0,0 +1,57 @@ +package main + +import ( + "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ecs" + "github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/ecr" + ecsx "github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/ecs" + "github.com/pulumi/pulumi-awsx/sdk/v2/go/awsx/lb" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + _, err := ecr.NewRepository(ctx, "repo", &ecr.RepositoryArgs{ + ForceDelete: pulumi.Bool(true), + }) + if err != nil { + return err + } + + lb, err := lb.NewApplicationLoadBalancer(ctx, "lb", nil) + if err != nil { + return err + } + + cluster, err := ecs.NewCluster(ctx, "cluster", nil) + if err != nil { + return err + } + + _, err = ecsx.NewFargateService(ctx, "service", &ecsx.FargateServiceArgs{ + Cluster: cluster.Arn, + AssignPublicIp: pulumi.Bool(true), + DesiredCount: pulumi.Int(2), + TaskDefinitionArgs: &ecsx.FargateServiceTaskDefinitionArgs{ + Container: &ecsx.TaskDefinitionContainerDefinitionArgs{ + Name: pulumi.String("my-service"), + Image: pulumi.String("nginx:latest"), + Cpu: pulumi.Int(128), + Memory: pulumi.Int(512), + Essential: pulumi.Bool(true), + PortMappings: ecsx.TaskDefinitionPortMappingArray{ + &ecsx.TaskDefinitionPortMappingArgs{ + ContainerPort: pulumi.Int(80), + TargetGroup: lb.DefaultTargetGroup, + }, + }, + }, + }, + }) + if err != nil { + return err + } + + ctx.Export("url", pulumi.Sprintf("http://%s", lb.LoadBalancer.DnsName())) + return nil + }) +} diff --git a/themes/default/static/examples/load-balanced-fargate-nginx-java/Pulumi.yaml b/themes/default/static/examples/load-balanced-fargate-nginx-java/Pulumi.yaml new file mode 100644 index 00000000000..695b8b91885 --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-nginx-java/Pulumi.yaml @@ -0,0 +1,3 @@ +name: load-balanced-fargate-nginx-yaml +runtime: java +description: A minimal AWS Pulumi YAML program diff --git a/themes/default/static/examples/load-balanced-fargate-nginx-java/pom.xml b/themes/default/static/examples/load-balanced-fargate-nginx-java/pom.xml new file mode 100644 index 00000000000..f7a83c2a0c9 --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-nginx-java/pom.xml @@ -0,0 +1,97 @@ + + + 4.0.0 + + com.pulumi + load-balanced-fargate-nginx-java + 1.0-SNAPSHOT + + + UTF-8 + 11 + 11 + 11 + myproject.App + + + + + + com.pulumi + pulumi + (,1.0] + + + com.pulumi + aws + (6.0.0,6.99] + + + com.pulumi + awsx + (2.0.0,2.99] + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.2 + + + + true + ${mainClass} + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.4.2 + + + + true + ${mainClass} + + + + jar-with-dependencies + + + + + make-my-jar-with-dependencies + package + + single + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.1.0 + + ${mainClass} + ${mainArgs} + + + + org.apache.maven.plugins + maven-wrapper-plugin + 3.1.1 + + 3.8.5 + + + + + diff --git a/themes/default/static/examples/load-balanced-fargate-nginx-java/src/main/java/myproject/App.java b/themes/default/static/examples/load-balanced-fargate-nginx-java/src/main/java/myproject/App.java new file mode 100644 index 00000000000..1059275311f --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-nginx-java/src/main/java/myproject/App.java @@ -0,0 +1,49 @@ +package myproject; + +import com.pulumi.Context; +import com.pulumi.Pulumi; +import com.pulumi.core.Output; +import com.pulumi.awsx.ecr.Repository; +import com.pulumi.awsx.ecr.RepositoryArgs; +import com.pulumi.aws.ecs.Cluster; +import com.pulumi.awsx.lb.ApplicationLoadBalancer; +import com.pulumi.awsx.ecs.FargateService; +import com.pulumi.awsx.ecs.FargateServiceArgs; +import com.pulumi.awsx.ecs.inputs.FargateServiceTaskDefinitionArgs; +import com.pulumi.awsx.ecs.inputs.TaskDefinitionContainerDefinitionArgs; +import com.pulumi.awsx.ecs.inputs.TaskDefinitionPortMappingArgs; + +public class App { + public static void main(String[] args) { + Pulumi.run(App::stack); + } + + public static void stack(Context ctx) { + var repository = new Repository("repository", RepositoryArgs.builder() + .forceDelete(true) + .build()); + + var cluster = new Cluster("cluster"); + var lb = new ApplicationLoadBalancer("lb"); + + var service = new FargateService("service", FargateServiceArgs.builder() + .cluster(cluster.arn()) + .assignPublicIp(true) + .taskDefinitionArgs(FargateServiceTaskDefinitionArgs.builder() + .container(TaskDefinitionContainerDefinitionArgs.builder() + .name("my-service") + .image("nginx:latest") + .cpu(128) + .memory(512) + .essential(true) + .portMappings(TaskDefinitionPortMappingArgs.builder() + .containerPort(80) + .targetGroup(lb.defaultTargetGroup()) + .build()) + .build()) + .build()) + .build()); + + ctx.export("url", Output.format("http://%s", lb.loadBalancer().applyValue(loadBalancer -> loadBalancer.dnsName()))); + } +} diff --git a/themes/default/static/examples/load-balanced-fargate-nginx-javascript/Pulumi.yaml b/themes/default/static/examples/load-balanced-fargate-nginx-javascript/Pulumi.yaml new file mode 100644 index 00000000000..227913fbd6c --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-nginx-javascript/Pulumi.yaml @@ -0,0 +1,6 @@ +name: load-balanced-fargate-nginx-javascript +runtime: + name: nodejs + options: + typescript: false +description: A minimal AWS Pulumi YAML program diff --git a/themes/default/static/examples/load-balanced-fargate-nginx-javascript/index.js b/themes/default/static/examples/load-balanced-fargate-nginx-javascript/index.js new file mode 100644 index 00000000000..e59223a55d4 --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-nginx-javascript/index.js @@ -0,0 +1,32 @@ +"use strict"; +const pulumi = require("@pulumi/pulumi"); +const aws = require("@pulumi/aws"); +const awsx = require("@pulumi/awsx"); + +const repo = new awsx.ecr.Repository("repo", { + forceDelete: true +}); + +const lb = new awsx.lb.ApplicationLoadBalancer("lb"); +const cluster = new aws.ecs.Cluster("cluster"); + +const service = new awsx.ecs.FargateService("service", { + cluster: cluster.arn, + assignPublicIp: true, + desiredCount: 2, + taskDefinitionArgs: { + container: { + name: "my-service", + image: "nginx:latest", + cpu: 128, + memory: 512, + essential: true, + portMappings: [{ + containerPort: 80, + targetGroup: lb.defaultTargetGroup, + }], + }, + }, +}); + +exports.url = pulumi.interpolate`http://${lb.loadBalancer.dnsName}`; diff --git a/themes/default/static/examples/load-balanced-fargate-nginx-javascript/package.json b/themes/default/static/examples/load-balanced-fargate-nginx-javascript/package.json new file mode 100644 index 00000000000..e1c315987aa --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-nginx-javascript/package.json @@ -0,0 +1,12 @@ +{ + "name": "load-balanced-fargate-nginx-javascript", + "devDependencies": { + "@types/node": "^14" + }, + "dependencies": { + "typescript": "^4.0.0", + "@pulumi/pulumi": "^3.0.0", + "@pulumi/aws": "^6.0.0", + "@pulumi/awsx": "^2.0.0" + } +} diff --git a/themes/default/static/examples/load-balanced-fargate-nginx-python/Pulumi.yaml b/themes/default/static/examples/load-balanced-fargate-nginx-python/Pulumi.yaml new file mode 100644 index 00000000000..97dabeb0001 --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-nginx-python/Pulumi.yaml @@ -0,0 +1,3 @@ +name: load-balanced-fargate-nginx-python +runtime: python +description: A minimal AWS Pulumi YAML program diff --git a/themes/default/static/examples/load-balanced-fargate-nginx-python/__main__.py b/themes/default/static/examples/load-balanced-fargate-nginx-python/__main__.py new file mode 100644 index 00000000000..e27fd9d48d2 --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-nginx-python/__main__.py @@ -0,0 +1,33 @@ +import pulumi +import pulumi_aws as aws +import pulumi_awsx as awsx + +repository = awsx.ecr.Repository( + "repository", + awsx.ecr.RepositoryArgs( + force_delete=True + ), +) + +lb = awsx.lb.ApplicationLoadBalancer("lb") +cluster = aws.ecs.Cluster("cluster") + +service = awsx.ecs.FargateService("service", + cluster=cluster.arn, + assign_public_ip=True, + desired_count=2, + task_definition_args=awsx.ecs.FargateServiceTaskDefinitionArgs( + container=awsx.ecs.TaskDefinitionContainerDefinitionArgs( + name="my-service", + image="nginx:latest", + cpu=128, + memory=512, + essential=True, + port_mappings=[awsx.ecs.TaskDefinitionPortMappingArgs( + container_port=80, + target_group=lb.default_target_group, + )], + ), + )) + +pulumi.export("url", pulumi.Output.concat("http://", lb.load_balancer.dns_name)) diff --git a/themes/default/static/examples/load-balanced-fargate-nginx-python/requirements.txt b/themes/default/static/examples/load-balanced-fargate-nginx-python/requirements.txt new file mode 100644 index 00000000000..961f30bc6eb --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-nginx-python/requirements.txt @@ -0,0 +1,3 @@ +pulumi>=3.0.0,<4.0.0 +pulumi-aws>=6.0.0,<7.0.0 +pulumi-awsx>=2.0.0,<3.0.0 diff --git a/themes/default/static/examples/load-balanced-fargate-nginx-typescript/Pulumi.yaml b/themes/default/static/examples/load-balanced-fargate-nginx-typescript/Pulumi.yaml new file mode 100644 index 00000000000..c2ea12deb2f --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-nginx-typescript/Pulumi.yaml @@ -0,0 +1,3 @@ +name: load-balanced-fargate-nginx-typescript +runtime: nodejs +description: A minimal AWS Pulumi YAML program diff --git a/themes/default/static/examples/load-balanced-fargate-nginx-typescript/index.ts b/themes/default/static/examples/load-balanced-fargate-nginx-typescript/index.ts new file mode 100644 index 00000000000..62bde5dda70 --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-nginx-typescript/index.ts @@ -0,0 +1,31 @@ +import * as pulumi from "@pulumi/pulumi"; +import * as aws from "@pulumi/aws"; +import * as awsx from "@pulumi/awsx"; + +const repo = new awsx.ecr.Repository("repo", { + forceDelete: true +}); + +const lb = new awsx.lb.ApplicationLoadBalancer("lb"); +const cluster = new aws.ecs.Cluster("cluster"); + +const service = new awsx.ecs.FargateService("service", { + cluster: cluster.arn, + assignPublicIp: true, + desiredCount: 2, + taskDefinitionArgs: { + container: { + name: "my-service", + image: "nginx:latest", + cpu: 128, + memory: 512, + essential: true, + portMappings: [{ + containerPort: 80, + targetGroup: lb.defaultTargetGroup, + }], + }, + }, +}); + +export const url = pulumi.interpolate`http://${lb.loadBalancer.dnsName}`; diff --git a/themes/default/static/examples/load-balanced-fargate-nginx-typescript/package.json b/themes/default/static/examples/load-balanced-fargate-nginx-typescript/package.json new file mode 100644 index 00000000000..cfeaa1ecea1 --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-nginx-typescript/package.json @@ -0,0 +1,12 @@ +{ + "name": "load-balanced-fargate-nginx-typescript", + "devDependencies": { + "@types/node": "^14" + }, + "dependencies": { + "typescript": "^4.0.0", + "@pulumi/pulumi": "^3.0.0", + "@pulumi/aws": "^6.0.0", + "@pulumi/awsx": "^2.0.0" + } +} diff --git a/themes/default/static/examples/load-balanced-fargate-nginx-typescript/tsconfig.json b/themes/default/static/examples/load-balanced-fargate-nginx-typescript/tsconfig.json new file mode 100644 index 00000000000..11fc69af240 --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-nginx-typescript/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "strict": true, + "outDir": "bin", + "target": "es2016", + "module": "commonjs", + "moduleResolution": "node", + "sourceMap": true, + "experimentalDecorators": true, + "pretty": true, + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.ts", + ] +} \ No newline at end of file diff --git a/themes/default/static/examples/load-balanced-fargate-nginx-yaml/Pulumi.yaml b/themes/default/static/examples/load-balanced-fargate-nginx-yaml/Pulumi.yaml new file mode 100644 index 00000000000..cc72fd06455 --- /dev/null +++ b/themes/default/static/examples/load-balanced-fargate-nginx-yaml/Pulumi.yaml @@ -0,0 +1,28 @@ +name: load-balanced-fargate-nginx-yaml +runtime: yaml +resources: + repo: + type: awsx:ecr:Repository + properties: + forceDelete: true + lb: + type: awsx:lb:ApplicationLoadBalancer + cluster: + type: aws:ecs:Cluster + service: + type: awsx:ecs:FargateService + properties: + cluster: ${cluster.arn} + assignPublicIp: true + taskDefinitionArgs: + container: + name: my-service + image: "nginx:latest" + cpu: 128 + memory: 512 + essential: true + portMappings: + - containerPort: 80 + targetGroup: ${lb.defaultTargetGroup} +outputs: + url: http://${lb.loadBalancer.dnsName}