diff --git a/.github/workflows/scheduled-programs.yml b/.github/workflows/scheduled-programs.yml new file mode 100644 index 00000000000..aa65b7e1c9a --- /dev/null +++ b/.github/workflows/scheduled-programs.yml @@ -0,0 +1,77 @@ +name: Run example programs +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-programs diff --git a/.prettierignore b/.prettierignore index 5e39abbb810..e6f1333ed0c 100644 --- a/.prettierignore +++ b/.prettierignore @@ -15,3 +15,4 @@ yarn-error.log themes/default/theme themes/default/assets themes/default/layouts +themes/default/static/programs diff --git a/Makefile b/Makefile index e53065a3a59..a3ccb0a7c75 100644 --- a/Makefile +++ b/Makefile @@ -79,3 +79,6 @@ new-learn-topic: .PHONY: new-template new-template: ./scripts/content/new-template.sh + +test-programs: + ./scripts/test-programs.sh preview diff --git a/scripts/clean.sh b/scripts/clean.sh index f31fbb05ed2..458eb95fb9e 100755 --- a/scripts/clean.sh +++ b/scripts/clean.sh @@ -2,6 +2,8 @@ set -o errexit -o pipefail +git clean -fdX + yarn cache clean hugo mod clean diff --git a/scripts/test-programs.sh b/scripts/test-programs.sh new file mode 100755 index 00000000000..457ecffa97b --- /dev/null +++ b/scripts/test-programs.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +set -euo pipefail + +pulumi whoami -v + +# Delete build/test artifacts. +git clean -fdX themes/default/static/programs + +pushd themes/default/static/programs + 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" == "awsx-load-balanced-fargate-ecr-java" ]]; then + continue + elif [[ "$project" == "awsx-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/blog/aws-lambda-container-support/index.md b/themes/default/content/blog/aws-lambda-container-support/index.md index c90489a3f94..cafd543e20c 100644 --- a/themes/default/content/blog/aws-lambda-container-support/index.md +++ b/themes/default/content/blog/aws-lambda-container-support/index.md @@ -12,6 +12,10 @@ tags: - serverless --- +{{% notes type="warning" %}} +Some of the code in this post is out of date. See the [AWS guides](/docs/clouds/aws/guides/) for an updated overview and examples. +{{% /notes %}} + When AWS Lambda launched in 2014, it pioneered the concept of Function-as-a-Service. Developers could write a function in one of the supported programming languages, upload it to AWS, and Lambda executes the function on every invocation. Ever since then, a zip archive of application code or binaries has been the only supported deployment option. Even AWS Lambda Layers—reusable components automatically merged into the application code—used the zip packaging format. diff --git a/themes/default/content/blog/aws-lambda-efs/index.md b/themes/default/content/blog/aws-lambda-efs/index.md index 9592253cfde..cf680ad9af2 100644 --- a/themes/default/content/blog/aws-lambda-efs/index.md +++ b/themes/default/content/blog/aws-lambda-efs/index.md @@ -12,6 +12,10 @@ tags: - efs --- +{{% notes type="warning" %}} +Some of the code in this post is out of date. See the [AWS guides](/docs/clouds/aws/guides/) for an updated overview and examples. +{{% /notes %}} + Ever since AWS Lambda was released in 2015, users have wanted persistent file storage beyond the small 512MB `/tmp` disk allocated to each Lambda function. The following year, Amazon launched EFS, offering a simple managed file system service for AWS, but initially only available to mount onto Amazon EC2 instances. Over the last few months, AWS has been extending access to EFS to all of the modern compute offerings. First [EKS](https://aws.amazon.com/about-aws/whats-new/2019/09/amazon-eks-announces-beta-release-of-amazon-efs-csi-driver/) for Kubernetes, then [ECS and Fargate](https://aws.amazon.com/about-aws/whats-new/2020/04/amazon-ecs-aws-fargate-support-amazon-efs-filesystems-generally-available/) for containers. Today, AWS announced that [EFS is now also supported in Lambda](https://aws.amazon.com/blogs/aws/new-a-shared-file-system-for-your-lambda-functions/), providing easy access to network file systems from your serverless functions. diff --git a/themes/default/content/blog/building-and-publishing-docker-images-to-a-private-amazon-ecr-repository/index.md b/themes/default/content/blog/building-and-publishing-docker-images-to-a-private-amazon-ecr-repository/index.md index 1768e5b1642..618a0a62fd4 100644 --- a/themes/default/content/blog/building-and-publishing-docker-images-to-a-private-amazon-ecr-repository/index.md +++ b/themes/default/content/blog/building-and-publishing-docker-images-to-a-private-amazon-ecr-repository/index.md @@ -8,6 +8,9 @@ meta_desc: "See how Pulumi Crosswalk for AWS lets you use infrastructure as code meta_image: "pulumi-crosswalk-for-aws.png" --- +{{% notes type="warning" %}} +Some of the code in this post is out of date. See the [AWS guides](/docs/clouds/aws/guides/) for an updated overview and examples. +{{% /notes %}} Amazon Elastic Container Registry ([ECR](https://aws.amazon.com/ecr/)) is a fully-managed Docker container registry that makes it easy for diff --git a/themes/default/content/blog/crosswalk-for-aws-1-0/index.md b/themes/default/content/blog/crosswalk-for-aws-1-0/index.md index 11d33c69054..99bbbc3f15b 100644 --- a/themes/default/content/blog/crosswalk-for-aws-1-0/index.md +++ b/themes/default/content/blog/crosswalk-for-aws-1-0/index.md @@ -33,6 +33,10 @@ tags: # for additional details, and please remove these comments before submitting for review. --- +{{% notes type="warning" %}} +Portions of this blog post are out of date. See the [AWS guides](/docs/clouds/aws/guides/) for an updated overview and examples. +{{% /notes %}} + We introduced [Crosswalk for AWS](https://www.pulumi.com/docs/clouds/aws/guides/) three years ago as a library of components on top of the core AWS platform to make it easier to get from zero to production on AWS, easier to adopt AWS best practices by default, and easier to evolve your AWS infrastructure as your application needs mature. Since then, we’ve added many new capabilities, expanded the portfolio of libraries, and made these libraries [available to all Pulumi languages](https://www.pulumi.com/blog/crosswalk-for-aws-all-languages/). We’ve also seen thousands of Pulumi customers, including more than 25% of all Pulumi AWS users, adopting one or more of the Crosswalk for AWS components to aid in delivering their AWS-based applications and services. Today, we’re excited to deliver the 1.0 releases of the three core libraries that make up Crosswalk for AWS: [AWSX 1.0](https://www.pulumi.com/registry/packages/awsx/), [EKS 1.0](https://www.pulumi.com/registry/packages/eks/) and [AWS API Gateway 1.0](https://www.pulumi.com/registry/packages/aws-apigateway/). These 1.0 releases offer a stable supported foundation, available in all Pulumi languages, for these rich infrastructure components. diff --git a/themes/default/content/blog/crosswalk-for-aws-all-languages/index.md b/themes/default/content/blog/crosswalk-for-aws-all-languages/index.md index 1d2c331cda6..99740a2e1ad 100644 --- a/themes/default/content/blog/crosswalk-for-aws-all-languages/index.md +++ b/themes/default/content/blog/crosswalk-for-aws-all-languages/index.md @@ -32,6 +32,10 @@ tags: # for additional details, and please remove these comments before submitting for review. --- +{{% notes type="warning" %}} +Portions of this blog post are out of date. See the [AWS guides](/docs/clouds/aws/guides/) for an updated overview and examples. +{{% /notes %}} + Crosswalk for AWS is a collection of libraries that make it easy to work with AWS using Pulumi Infrastructure as Code. The Crosswalk for AWS libraries are some of the most widely used higher-level components in the Pulumi ecosystem, with hundreds of organizations building their infrastructure on the simple abstractions over key AWS services like ECS, API Gateway, VPC, Load Balancing, CloudTrail, EC2, ECR, and more. diff --git a/themes/default/content/blog/deploying-a-pern-stack-application-to-aws/index.md b/themes/default/content/blog/deploying-a-pern-stack-application-to-aws/index.md index c96fa655954..483fb48ac5f 100644 --- a/themes/default/content/blog/deploying-a-pern-stack-application-to-aws/index.md +++ b/themes/default/content/blog/deploying-a-pern-stack-application-to-aws/index.md @@ -7,6 +7,10 @@ authors: ["vova-ivanov"] tags: ["aws", "typescript", "containers", "docker"] --- +{{% notes type="warning" %}} +Some of the code in this post is out of date. See the [AWS guides](/docs/clouds/aws/guides/) for an updated overview and examples. +{{% /notes %}} + In this blog post, we will explore PERN stack applications and deploy one to AWS. *PERN* is an acronym for PostgreSQL, Express, React, and Node. A PERN stack application is a project that uses PostgreSQL, Express as an application framework, React as a user interface framework, and runs on Node. We will also use [Pulumi Crosswalk](/docs/clouds/aws/guides/) to reduce the amount of code and provide a quick and straightforward path for deploying the application. diff --git a/themes/default/content/blog/deploying-the-infrastructure-of-oauth-server-for-cms-app/index.md b/themes/default/content/blog/deploying-the-infrastructure-of-oauth-server-for-cms-app/index.md index 91f680805e0..ed1663d5b39 100644 --- a/themes/default/content/blog/deploying-the-infrastructure-of-oauth-server-for-cms-app/index.md +++ b/themes/default/content/blog/deploying-the-infrastructure-of-oauth-server-for-cms-app/index.md @@ -8,6 +8,10 @@ authors: ["zephyr-zhou"] tags: ["aws","github-actions", "netlify", "oauth", "ecs", "fargate"] --- +{{% notes type="warning" %}} +Some of the code in this post is out of date. See the [AWS guides](/docs/clouds/aws/guides/) for an updated overview and examples. +{{% /notes %}} + In our [previous post](/blog/deploying-netlify-cms-on-aws/), we deployed our CMS app on AWS instead of Netlify. We couldn't use [Netlify's Identity Service](https://docs.netlify.com/visitor-access/identity/#enable-identity-in-the-ui), which manages GitHub access to Netlify CMS, because we deployed on AWS. As a result, we needed to implement an external [OAuth Server](https://www.netlifycms.org/docs/external-oauth-clients/#header). We used Netlify's Go example to deploy on ECS Fargate and configure the domain and certificate. To deploy the application on Fargate, we used a Typescript Pulumi project. This is a polyglot application where the OAuth server is implemented in Go and the infrastructure is deployed with Typescript. We'll show how we accomplished the deployment. diff --git a/themes/default/content/blog/get-started-with-docker-on-aws-fargate-using-pulumi/index.md b/themes/default/content/blog/get-started-with-docker-on-aws-fargate-using-pulumi/index.md index 29f858df1a1..0d46f7dda75 100644 --- a/themes/default/content/blog/get-started-with-docker-on-aws-fargate-using-pulumi/index.md +++ b/themes/default/content/blog/get-started-with-docker-on-aws-fargate-using-pulumi/index.md @@ -7,6 +7,10 @@ authors: ["joe-duffy"] tags: ["JavaScript","AWS","containers","TypeScript"] --- +{{% notes type="warning" %}} +Some of the code in this post is out of date. See the [AWS guides](/docs/clouds/aws/guides/) for an updated overview and examples. +{{% /notes %}} + > Update: Check out the [Learning Machine Case Study](/case-studies/learning-machine/) where provisioning went from 3 weeks to 1 hour with Pulumi and AWS. > > *"The impact of serverless capabilities was also transformative for the Learning Machine business. Pulumi enabled a rapid shift to Amazon ECS, AWS Fargate and AWS Lambda — the net effect of which was a 67% reduction in AWS charges. This enabled the team to spend less time focused on maintaining existing infrastructure and more time deploying new applications on AWS and adding new customers.* diff --git a/themes/default/content/blog/introducing-pulumi-crosswalk-for-aws-the-easiest-way-to-aws/index.md b/themes/default/content/blog/introducing-pulumi-crosswalk-for-aws-the-easiest-way-to-aws/index.md index d37982d67c8..b6969b304b2 100644 --- a/themes/default/content/blog/introducing-pulumi-crosswalk-for-aws-the-easiest-way-to-aws/index.md +++ b/themes/default/content/blog/introducing-pulumi-crosswalk-for-aws-the-easiest-way-to-aws/index.md @@ -7,6 +7,10 @@ authors: ["luke-hoban"] tags: ["Serverless","AWS","containers","pulumi-news","Kubernetes","containers", "eks", "lambda", "api-gateway", "docker"] --- +{{% notes type="warning" %}} +Some of the code in this post is out of date. See the [AWS guides](/docs/clouds/aws/guides/) for an updated overview and examples. +{{% /notes %}} + Amazon Web Services provides an incredible platform for developers to build cloud-native applications, and is used by millions of customers of all sizes. The building block services that AWS offers enable teams to diff --git a/themes/default/content/blog/managing-containers-on-aws-with-pulumi/index.md b/themes/default/content/blog/managing-containers-on-aws-with-pulumi/index.md index 0cd452e7aff..0792a7ac1c6 100644 --- a/themes/default/content/blog/managing-containers-on-aws-with-pulumi/index.md +++ b/themes/default/content/blog/managing-containers-on-aws-with-pulumi/index.md @@ -13,6 +13,10 @@ tags: - lambda --- +{{% notes type="warning" %}} +Some of the code in this post is out of date. See the [AWS guides](/docs/clouds/aws/guides/) for an updated overview and examples. +{{% /notes %}} + The Amazon Web Services (AWS) Cloud ecosystem is large and vibrant, so vast and vibrant that at times, it can be challenging to know where best to start! In the case of [containers](https://www.pulumi.com/containers/), [Abby Fuller](https://twitter.com/abbyfuller) tweeted a descriptive summary about using AWS container services. diff --git a/themes/default/content/blog/nov-2022-launches/index.md b/themes/default/content/blog/nov-2022-launches/index.md index ee7dc48e8e9..36be40c9e02 100644 --- a/themes/default/content/blog/nov-2022-launches/index.md +++ b/themes/default/content/blog/nov-2022-launches/index.md @@ -10,6 +10,10 @@ tags: - pulumi-releases --- +{{% notes type="warning" %}} +Some of the code in this post is out of date. See the [AWS guides](/docs/clouds/aws/guides/) for an updated overview and examples. +{{% /notes %}} + Our mission at Pulumi is to enable teams to scale up what they can build in the cloud. Scale up the sophistication and value of their cloud infrastructure investments through software engineering practices. Scale up the automation around delivering cloud infrastructure with software instead of just humans. And scale up the number of developers who can directly benefit from the rich cloud platform capabilities being built by central platform teams in every organization today. As part of [Pulumi Cloud Engineering Days 2022](https://www.pulumi.com/cloud-engineering-days/) today we are announcing a set of important new advancements in the Pulumi platform which are all designed to help organizations scale with their infrastructure as code needs. diff --git a/themes/default/content/blog/pulumi-universal-iac/index.md b/themes/default/content/blog/pulumi-universal-iac/index.md index 4fbe280c6da..4d0fab0c6fb 100644 --- a/themes/default/content/blog/pulumi-universal-iac/index.md +++ b/themes/default/content/blog/pulumi-universal-iac/index.md @@ -11,6 +11,10 @@ tags: - crosswalk --- +{{% notes type="warning" %}} +Some of the code in this post is out of date. See the [AWS guides](/docs/clouds/aws/guides/) for an updated overview and examples. +{{% /notes %}} + Over the last year since the launch of Pulumi 3.0, we’ve seen incredible growth in adoption and usage of the Pulumi open source project and Cloud Engineering platform, with more than a thousand new open source contributors, tens of thousands of new users, and millions of new cloud infrastructure resources being managed by Pulumi. Pulumi’s infrastructure as code tools are enabling teams to scale up their cloud infrastructure with robust software engineering tools and practices to get the most value out of their cloud platform investments. Today, we’re excited to announce a wave of innovation across the Pulumi project with a collection of significant new feature launches. These new features bring together Pulumi’s __*Universal Infrastructure as Code*__ offering, supporting the widest range of builders, clouds, programming languages, and cloud architectures. diff --git a/themes/default/content/blog/run-your-own-rss-server/index.md b/themes/default/content/blog/run-your-own-rss-server/index.md index 5a3eb2d1a65..10ad6d99062 100644 --- a/themes/default/content/blog/run-your-own-rss-server/index.md +++ b/themes/default/content/blog/run-your-own-rss-server/index.md @@ -11,6 +11,10 @@ tags: - aws --- +{{% notes type="warning" %}} +Some of the code in this post is out of date. See the [AWS guides](/docs/clouds/aws/guides/) for an updated overview and examples. +{{% /notes %}} + It's been a few years since [Google shut down Google Reader](https://googleblog.blogspot.com/2013/03/a-second-spring-of-cleaning.html), and while a number of nice commercial alternatives have sprung in its wake, none of them has ever been quite the right fit for me personally. So a while back, after far too much time spent wandering the blogsphere manually, typing URLs into address bars by hand, I decided to go looking to see whether the universe had produced an open-source solution to this problem --- and to my surprise and delight, it had! [Miniflux](https://miniflux.app/) is an excellent little open-source RSS server and reader, written in Go and backed by PostgreSQL, that also happens to be packaged [as a Docker container](https://hub.docker.com/r/miniflux/miniflux). So in this post, I'll show how easy it is to deploy a Miniflux server of your own on AWS, using only Pulumi and a few lines of TypeScript. diff --git a/themes/default/content/blog/running-containers-in-aws-the-lowdown-ecs-fargate-and-eks/index.md b/themes/default/content/blog/running-containers-in-aws-the-lowdown-ecs-fargate-and-eks/index.md index abaab40052e..1cd0c822460 100644 --- a/themes/default/content/blog/running-containers-in-aws-the-lowdown-ecs-fargate-and-eks/index.md +++ b/themes/default/content/blog/running-containers-in-aws-the-lowdown-ecs-fargate-and-eks/index.md @@ -7,6 +7,10 @@ meta_desc: "Use Pulumi's infrastucture-as-code approach to simplify working with meta_image: "pulumi-crosswalk-for-aws.png" --- +{{% notes type="warning" %}} +Some of the code in this post is out of date. See the [AWS guides](/docs/clouds/aws/guides/) for an updated overview and examples. +{{% /notes %}} +
diff --git a/themes/default/content/docs/clouds/aws/guides/_index.md b/themes/default/content/docs/clouds/aws/guides/_index.md index 32ae6abba43..c2d456a95af 100644 --- a/themes/default/content/docs/clouds/aws/guides/_index.md +++ b/themes/default/content/docs/clouds/aws/guides/_index.md @@ -39,38 +39,93 @@ For example, this program builds and publishes a Dockerized application to a pri ecr), spins up an ECS Fargate cluster, and runs a scalable, load balanced service, all in response to a single `pulumi up` command line invocation: -{{< chooser language "typescript,python,go,csharp,java,yaml" / >}} +{{< chooser language "javascript,typescript,python,go,csharp,java,yaml" / >}} -{{% choosable language "javascript,typescript" %}} +{{% 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 repository = new awsx.ecr.Repository("repository", {}); +const repo = new awsx.ecr.Repository("repo", { + forceDelete: true, +}); + const image = new awsx.ecr.Image("image", { - repositoryUrl: repository.url, - path: "./app", + repositoryUrl: repo.url, + context: "./app", + platform: "linux/amd64", }); -const cluster = new aws.ecs.Cluster("cluster", {}); -const lb = new awsx.lb.ApplicationLoadBalancer("lb", {}); + +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: 512, - memory: 128, + cpu: 128, + memory: 512, essential: true, portMappings: [{ + containerPort: 80, targetGroup: lb.defaultTargetGroup, }], }, }, }); -export const url = lb.loadBalancer.dnsName; + +export const url = pulumi.interpolate`http://${lb.loadBalancer.dnsName}`; ``` {{% /choosable %}} @@ -82,27 +137,47 @@ 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") +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", - 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, - )], + +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", lb.load_balancer.dns_name) + ), +) + +pulumi.export("url", pulumi.Output.concat("http://", lb.load_balancer.dns_name)) ``` {{% /choosable %}} @@ -113,47 +188,55 @@ pulumi.export("url", lb.load_balancer.dns_name) package main import ( - "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ecs" - "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/lb" - "github.com/pulumi/pulumi-awsx/sdk/go/awsx/ecr" - "github.com/pulumi/pulumi-awsx/sdk/go/awsx/ecs" - "github.com/pulumi/pulumi-awsx/sdk/go/awsx/lb" + "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", nil) + 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, - Path: pulumi.String("./app"), + 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 = ecs.NewFargateService(ctx, "service", &ecs.FargateServiceArgs{ + + _, err = ecsx.NewFargateService(ctx, "service", &ecsx.FargateServiceArgs{ Cluster: cluster.Arn, AssignPublicIp: pulumi.Bool(true), - TaskDefinitionArgs: &ecs.FargateServiceTaskDefinitionArgs{ - Container: &ecs.TaskDefinitionContainerDefinitionArgs{ + TaskDefinitionArgs: &ecsx.FargateServiceTaskDefinitionArgs{ + Container: &ecsx.TaskDefinitionContainerDefinitionArgs{ + Name: pulumi.String("app"), Image: image.ImageUri, - Cpu: pulumi.Int(512), - Memory: pulumi.Int(128), + Cpu: pulumi.Int(128), + Memory: pulumi.Int(512), Essential: pulumi.Bool(true), - PortMappings: []ecs.TaskDefinitionPortMappingArgs{ - &ecs.TaskDefinitionPortMappingArgs{ - TargetGroup: lb.DefaultTargetGroup, + PortMappings: ecsx.TaskDefinitionPortMappingArray{ + &ecsx.TaskDefinitionPortMappingArgs{ + ContainerPort: pulumi.Int(80), + TargetGroup: lb.DefaultTargetGroup, }, }, }, @@ -162,9 +245,8 @@ func main() { if err != nil { return err } - ctx.Export("url", lb.LoadBalancer.ApplyT(func(loadBalancer *lb.LoadBalancer) (string, error) { - return loadBalancer.DnsName, nil - }).(pulumi.StringOutput)) + + ctx.Export("url", pulumi.Sprintf("http://%s", lb.LoadBalancer.DnsName())) return nil }) } @@ -182,19 +264,23 @@ using Awsx = Pulumi.Awsx; return await Deployment.RunAsync(() => { - var repository = new Awsx.Ecr.Repository("repository"); + var cluster = new Aws.Ecs.Cluster("cluster"); - var image = new Awsx.Ecr.Image("image", new() + var repo = new Awsx.Ecr.Repository("repo", new() { - RepositoryUrl = repository.Url, - Path = "./app", + ForceDelete = true, }); - var cluster = new Aws.Ecs.Cluster("cluster"); + 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() + var service = new Awsx.Ecs.FargateService("service", new Awsx.Ecs.FargateServiceArgs { Cluster = cluster.Arn, AssignPublicIp = true, @@ -202,14 +288,16 @@ return await Deployment.RunAsync(() => { Container = new Awsx.Ecs.Inputs.TaskDefinitionContainerDefinitionArgs { + Name = "my-service", Image = image.ImageUri, - Cpu = 512, - Memory = 128, + Cpu = 128, + Memory = 512, Essential = true, PortMappings = new[] { new Awsx.Ecs.Inputs.TaskDefinitionPortMappingArgs { + ContainerPort = 80, TargetGroup = lb.DefaultTargetGroup, }, }, @@ -219,10 +307,9 @@ return await Deployment.RunAsync(() => return new Dictionary { - ["url"] = lb.LoadBalancer.Apply(loadBalancer => loadBalancer.DnsName), + ["url"] = lb.LoadBalancer.Apply(loadBalancer => Output.Format($"http://{loadBalancer.DnsName}")), }; }); - ``` {{% /choosable %}} @@ -230,12 +317,13 @@ return await Deployment.RunAsync(() => {{% choosable language java %}} ```java -package generated_program; +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; @@ -244,12 +332,7 @@ 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; +import com.pulumi.awsx.ecs.inputs.TaskDefinitionPortMappingArgs; public class App { public static void main(String[] args) { @@ -257,11 +340,14 @@ public class App { } public static void stack(Context ctx) { - var repository = new Repository("repository"); + var repository = new Repository("repository", RepositoryArgs.builder() + .forceDelete(true) + .build()); var image = new Image("image", ImageArgs.builder() .repositoryUrl(repository.url()) - .path("./app") + .context("./app") + .platform("linux/amd64") .build()); var cluster = new Cluster("cluster"); @@ -273,18 +359,20 @@ public class App { .assignPublicIp(true) .taskDefinitionArgs(FargateServiceTaskDefinitionArgs.builder() .container(TaskDefinitionContainerDefinitionArgs.builder() + .name("my-service") .image(image.imageUri()) - .cpu(512) - .memory(128) + .cpu(128) + .memory(512) .essential(true) .portMappings(TaskDefinitionPortMappingArgs.builder() + .containerPort(80) .targetGroup(lb.defaultTargetGroup()) .build()) .build()) .build()) .build()); - ctx.export("url", lb.loadBalancer().applyValue(loadBalancer -> loadBalancer.dnsName())); + ctx.export("url", Output.format("http://%s", lb.loadBalancer().applyValue(loadBalancer -> loadBalancer.dnsName()))); } } ``` @@ -294,21 +382,28 @@ public class App { {{% choosable language yaml %}} ```yaml -name: scratch-yaml -description: A Pulumi YAML program to deploy a serverless application on AWS +name: my-project runtime: yaml + resources: - repository: + repo: type: awsx:ecr:Repository + properties: + forceDelete: true + + lb: + type: awsx:lb:ApplicationLoadBalancer + image: type: awsx:ecr:Image properties: - repositoryUrl: ${repository.url} - path: "./app" + repositoryUrl: ${repo.url} + context: ./app + platform: linux/amd64 + cluster: type: aws:ecs:Cluster - lb: - type: awsx:lb:ApplicationLoadBalancer + service: type: awsx:ecs:FargateService properties: @@ -316,14 +411,17 @@ resources: assignPublicIp: true taskDefinitionArgs: container: + name: my-service image: ${image.imageUri} - cpu: 512 - memory: 128 + cpu: 128 + memory: 512 essential: true portMappings: - - targetGroup: ${lb.defaultTargetGroup} + - containerPort: 80 + targetGroup: ${lb.defaultTargetGroup} + outputs: - url: ${lb.loadBalancer.dnsName} + url: http://${lb.loadBalancer.dnsName} ``` {{% /choosable %}} diff --git a/themes/default/content/docs/clouds/aws/guides/ecr.md b/themes/default/content/docs/clouds/aws/guides/ecr.md index 2752aff7ca7..94c7b4e3ec4 100644 --- a/themes/default/content/docs/clouds/aws/guides/ecr.md +++ b/themes/default/content/docs/clouds/aws/guides/ecr.md @@ -40,16 +40,27 @@ https://docs.aws.amazon.com/AmazonECR/latest/userguide/Repositories.html) to act To create a new ECR repository, allocate an instance of the `awsx.ecr.Repository` class: -{{< chooser language "typescript,python,go,csharp,java,yaml" / >}} +{{< chooser language "javascript,typescript,python,go,csharp,java,yaml" / >}} -{{% choosable language "javascript,typescript" %}} +{{% choosable language "javascript" %}} + +```javascript +"use strict"; +const awsx = require("@pulumi/awsx"); + +const repo = new awsx.ecr.Repository("repo"); +exports.url = repo.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", {}); -export const url = repository.url; +const repo = new awsx.ecr.Repository("repo"); +export const url = repo.url; ``` {{% /choosable %}} @@ -82,6 +93,7 @@ func main() { if err != nil { return err } + ctx.Export("url", repository.Url) return nil }) @@ -251,150 +263,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 "typescript,python,go,csharp,java,yaml" / >}} - -{{% choosable language "javascript,typescript" %}} - -```typescript -import * as pulumi from "@pulumi/pulumi"; -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", -}); -export const url = repository.url; -``` - -{{% /choosable %}} - -{{% choosable language python %}} - -```python -import pulumi -import pulumi_awsx as awsx - -repository = awsx.ecr.Repository("repository") -image = awsx.ecr.Image("image", - repository_url=repository.url, - path="./app") -pulumi.export("url", repository.url) -``` - -{{% /choosable %}} - -{{% choosable language go %}} - -```go -package main - -import ( - "github.com/pulumi/pulumi-awsx/sdk/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", nil) - if err != nil { - return err - } - _, err = ecr.NewImage(ctx, "image", &ecr.ImageArgs{ - RepositoryUrl: repository.Url, - Path: pulumi.String("./app"), - }) - 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"); - - var image = new Awsx.Ecr.Image("image", new() - { - RepositoryUrl = repository.Url, - Path = "./app", - }); - - return new Dictionary - { - ["url"] = repository.Url, - }; -}); -``` - -{{% /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 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()); - - ctx.export("url", repository.url()); - } -} -``` - -{{% /choosable %}} - -{{% choosable language yaml %}} - -```yaml -resources: - repository: - type: awsx:ecr:Repository - image: - type: awsx:ecr:Image - properties: - repositoryUrl: ${repository.url} - path: "./app" -outputs: - url: ${repository.url} -``` - -{{% /choosable %}} +{{< example-program path="awsx-ecr-image" >}} 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: @@ -443,294 +312,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 "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-aws/sdk/v5/go/aws/lb" - "github.com/pulumi/pulumi-awsx/sdk/go/awsx/ecr" - "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, - Path: pulumi.String("./app"), - }) - 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 = ecs.NewFargateService(ctx, "service", &ecs.FargateServiceArgs{ - Cluster: cluster.Arn, - AssignPublicIp: pulumi.Bool(true), - TaskDefinitionArgs: &ecs.FargateServiceTaskDefinitionArgs{ - Container: &ecs.TaskDefinitionContainerDefinitionArgs{ - Image: image.ImageUri, - Cpu: pulumi.Int(512), - Memory: pulumi.Int(128), - Essential: pulumi.Bool(true), - PortMappings: []ecs.TaskDefinitionPortMappingArgs{ - &ecs.TaskDefinitionPortMappingArgs{ - TargetGroup: lb.DefaultTargetGroup, - }, - }, - }, - }, - }) - if err != nil { - return err - } - ctx.Export("url", lb.LoadBalancer.ApplyT(func(loadBalancer *lb.LoadBalancer) (string, error) { - return loadBalancer.DnsName, nil - }).(pulumi.StringOutput)) - return nil - }) -} -``` - -{{% /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 -name: scratch-yaml -description: A Pulumi YAML program to deploy a serverless application on AWS -runtime: 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-program path="awsx-load-balanced-fargate-ecr" >}} 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 @@ -740,559 +322,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 "typescript,python,go,csharp,java,yaml" / >}} - -{{% choosable language "javascript,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", {}); -const image = new awsx.ecr.Image("image", { - repositoryUrl: repository.url, - path: "./app", -}); -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") -image = awsx.ecr.Image("image", - repository_url=repository.url, - path="./app") -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/go/awsx/ecr" - "github.com/pulumi/pulumi-eks/sdk/go/eks" - "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes" - appsv1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/apps/v1" - corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1" - metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/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", nil) - if err != nil { - return err - } - image, err := ecr.NewImage(ctx, "image", &ecr.ImageArgs{ - RepositoryUrl: repository.Url, - Path: pulumi.String("./app"), - }) - 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.Kubeconfig.AsStringPtrOutput(), - 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 - } - ctx.Export("url", service.Status.ApplyT(func(status corev1.ServiceStatus) (*string, error) { - return status.LoadBalancer.Ingress[0].Hostname, nil - }).(pulumi.StringPtrOutput)) - 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"); - - var image = new Awsx.Ecr.Image("image", new() - { - RepositoryUrl = repository.Url, - Path = "./app", - }); - - var cluster = new Eks.Cluster("cluster"); - - var clusterProvider = new Kubernetes.Provider("clusterProvider", new() - { - KubeConfig = cluster.Kubeconfig, - 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, - }); - - return new Dictionary - { - ["url"] = service.Status.Apply(status => status?.LoadBalancer?.Ingress[0]?.Hostname), - }; -}); -``` - -{{% /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.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.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.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) { - final var appName = "my-app"; - - var repository = new Repository("repository"); - - var image = new Image("image", ImageArgs.builder() - .repositoryUrl(repository.url()) - .path("./app") - .build()); - - var cluster = new Cluster("cluster"); - - var clusterProvider = new Provider("clusterProvider", ProviderArgs.builder() - .kubeconfig(cluster.kubeconfig()) - .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", service.status().applyValue(status -> status.loadBalancer().ingress()[0].hostname())); - } -} -``` - -{{% /choosable %}} - -{{% choosable language yaml %}} - -```yaml -variables: - appName: my-app -resources: - repository: - type: awsx:ecr:Repository - image: - type: awsx:ecr:Image - properties: - repositoryUrl: ${repository.url} - path: "./app" - cluster: - type: eks:Cluster - clusterProvider: - type: pulumi:providers:kubernetes - properties: - kubeconfig: ${cluster.kubeconfig} - 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: ${service.status.loadBalancer.ingress[0].hostname} -``` - -{{% /choosable %}} +{{< example-program path="awsx-ecr-eks-deployment-service" >}} 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..0759c3ef6eb 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-program path="awsx-load-balanced-fargate-nginx" >}} 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-program path="awsx-vpc-fargate-service" >}} 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-program path="awsx-load-balanced-fargate-ecr" >}} 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-program-snippet.html b/themes/default/layouts/shortcodes/example-program-snippet.html new file mode 100644 index 00000000000..cf61bb04823 --- /dev/null +++ b/themes/default/layouts/shortcodes/example-program-snippet.html @@ -0,0 +1,44 @@ +{{- $path := .Get "path" -}} +{{- $language := .Get "language" -}} +{{- $from := .Get "from" -}} +{{- $to := .Get "to" -}} +{{- $program := "" -}} +{{- $depfile := "" -}} +{{- $deplang := "" -}} +{{- if eq $language "javascript" -}} + {{- $program = "index.js" -}} + {{- $depfile = "package.json" -}} + {{- $deplang = "json" -}} +{{- else if eq $language "typescript" -}} + {{- $program = "index.ts" -}} + {{- $depfile = "package.json" -}} + {{- $deplang = "json" -}} +{{- else if eq $language "python" -}} + {{- $program = "__main__.py" -}} + {{- $depfile = "requirements.txt" -}} + {{- $deplang = "plain" -}} +{{- else if eq $language "go" -}} + {{- $program = "main.go" -}} + {{- $depfile = "go.mod" -}} + {{- $deplang = "bash" -}} +{{- else if eq $language "csharp" -}} + {{- $program = "Program.cs" -}} + {{- $depfile = printf "%s.csproj" (printf "%s-%s" $path $language) -}} + {{- $deplang = "xml" -}} +{{- else if eq $language "java" -}} + {{- $program = "src/main/java/myproject/App.java" -}} + {{- $depfile = "pom.xml" -}} + {{- $deplang = "xml" -}} +{{- else if eq $language "yaml" -}} + {{- $program = "Pulumi.yaml" -}} +{{- end -}} +{{- $file := readFile (path.Join "static" "programs" (printf "%s-%s" $path $language) $program) -}} +{{- 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" -}} +{{- else -}} + {{- $file -}} +{{- end -}} diff --git a/themes/default/layouts/shortcodes/example-program.html b/themes/default/layouts/shortcodes/example-program.html new file mode 100644 index 00000000000..99bc7b66bf5 --- /dev/null +++ b/themes/default/layouts/shortcodes/example-program.html @@ -0,0 +1,54 @@ +{{ $path := .Get "path" }} +{{ $languages := default "javascript,typescript,python,go,csharp,java,yaml" (.Get "languages") }} +{{ $folder := path.Join "static" "programs" }} + +
+ +
+ +{{ range $i, $language := split $languages "," }} +
+ +
+ {{ $program := "" }} + {{ $depfile := "" }} + {{ $deplang := "" }} + {{ if eq $language "javascript" }} + {{ $program = "index.js" }} + {{ $depfile = "package.json" }} + {{ $deplang = "json" }} + {{ else if eq $language "typescript" }} + {{ $program = "index.ts" }} + {{ $depfile = "package.json" }} + {{ $deplang = "json" }} + {{ else if eq $language "python" }} + {{ $program = "__main__.py" }} + {{ $depfile = "requirements.txt" }} + {{ $deplang = "plain" }} + {{ else if eq $language "go" }} + {{ $program = "main.go" }} + {{ $depfile = "go.mod" }} + {{ $deplang = "bash" }} + {{ else if eq $language "csharp" }} + {{ $program = "Program.cs" }} + {{ $depfile = printf "%s.csproj" (printf "%s-%s" $path $language) }} + {{ $deplang = "xml" }} + {{ else if eq $language "java" }} + {{ $program = "src/main/java/myproject/App.java" }} + {{ $depfile = "pom.xml" }} + {{ $deplang = "xml" }} + {{ else if eq $language "yaml" }} + {{ $program = "Pulumi.yaml" }} + {{ end }} + {{ if ne $program "" }} + {{ $root := slice "static" "programs" (printf "%s-%s" $path $language) }} + {{ $code := readFile (path.Join $root $program) }} + {{ $info := os.Stat (path.Join $root) }} +
+ {{ highlight $code $language }} +
+ {{ end }} +
+
+
+{{ end }} diff --git a/themes/default/static/programs/.gitignore b/themes/default/static/programs/.gitignore new file mode 100644 index 00000000000..25a0ccf643d --- /dev/null +++ b/themes/default/static/programs/.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 +!.gitignore + +# Lockfiles. +go.sum +package-lock.json +yarn.lock + +# Stack config files. +Pulumi.*.yaml diff --git a/themes/default/static/programs/awsx-ecr-eks-deployment-service-csharp/Program.cs b/themes/default/static/programs/awsx-ecr-eks-deployment-service-csharp/Program.cs new file mode 100644 index 00000000000..a91750d9665 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-eks-deployment-service-csharp/Pulumi.yaml b/themes/default/static/programs/awsx-ecr-eks-deployment-service-csharp/Pulumi.yaml new file mode 100644 index 00000000000..1a3e4a785e8 --- /dev/null +++ b/themes/default/static/programs/awsx-ecr-eks-deployment-service-csharp/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-ecr-eks-deployment-service-csharp +runtime: dotnet diff --git a/themes/default/static/programs/awsx-ecr-eks-deployment-service-csharp/app/Dockerfile b/themes/default/static/programs/awsx-ecr-eks-deployment-service-csharp/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-eks-deployment-service-csharp/awsx-ecr-eks-deployment-service-csharp.csproj b/themes/default/static/programs/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/programs/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/programs/awsx-ecr-eks-deployment-service-go/Pulumi.yaml b/themes/default/static/programs/awsx-ecr-eks-deployment-service-go/Pulumi.yaml new file mode 100644 index 00000000000..787a3e6b0bf --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-eks-deployment-service-go/go.mod b/themes/default/static/programs/awsx-ecr-eks-deployment-service-go/go.mod new file mode 100644 index 00000000000..8c1f065a814 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-eks-deployment-service-go/main.go b/themes/default/static/programs/awsx-ecr-eks-deployment-service-go/main.go new file mode 100644 index 00000000000..9d462ae84a3 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-eks-deployment-service-java/Pulumi.yaml b/themes/default/static/programs/awsx-ecr-eks-deployment-service-java/Pulumi.yaml new file mode 100644 index 00000000000..25e7df35300 --- /dev/null +++ b/themes/default/static/programs/awsx-ecr-eks-deployment-service-java/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-ecr-eks-deployment-service-java +runtime: java diff --git a/themes/default/static/programs/awsx-ecr-eks-deployment-service-java/app/Dockerfile b/themes/default/static/programs/awsx-ecr-eks-deployment-service-java/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-eks-deployment-service-java/pom.xml b/themes/default/static/programs/awsx-ecr-eks-deployment-service-java/pom.xml new file mode 100644 index 00000000000..a75a8e78bcb --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-eks-deployment-service-java/src/main/java/myproject/App.java b/themes/default/static/programs/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/programs/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/programs/awsx-ecr-eks-deployment-service-javascript/Pulumi.yaml b/themes/default/static/programs/awsx-ecr-eks-deployment-service-javascript/Pulumi.yaml new file mode 100644 index 00000000000..8eb1f8d881a --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-eks-deployment-service-javascript/index.js b/themes/default/static/programs/awsx-ecr-eks-deployment-service-javascript/index.js new file mode 100644 index 00000000000..c3867aa778c --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-eks-deployment-service-javascript/package.json b/themes/default/static/programs/awsx-ecr-eks-deployment-service-javascript/package.json new file mode 100644 index 00000000000..e05af511ac7 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-eks-deployment-service-python/Pulumi.yaml b/themes/default/static/programs/awsx-ecr-eks-deployment-service-python/Pulumi.yaml new file mode 100644 index 00000000000..1610fdbf79a --- /dev/null +++ b/themes/default/static/programs/awsx-ecr-eks-deployment-service-python/Pulumi.yaml @@ -0,0 +1,5 @@ +name: awsx-ecr-eks-deployment-service-python +runtime: + name: python + options: + virtualenv: venv diff --git a/themes/default/static/programs/awsx-ecr-eks-deployment-service-python/__main__.py b/themes/default/static/programs/awsx-ecr-eks-deployment-service-python/__main__.py new file mode 100644 index 00000000000..feb4a43c090 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-eks-deployment-service-python/app/Dockerfile b/themes/default/static/programs/awsx-ecr-eks-deployment-service-python/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-eks-deployment-service-python/requirements.txt b/themes/default/static/programs/awsx-ecr-eks-deployment-service-python/requirements.txt new file mode 100644 index 00000000000..e2cdbc80eb6 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-eks-deployment-service-typescript/Pulumi.yaml b/themes/default/static/programs/awsx-ecr-eks-deployment-service-typescript/Pulumi.yaml new file mode 100644 index 00000000000..705d13bb168 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-eks-deployment-service-typescript/index.ts b/themes/default/static/programs/awsx-ecr-eks-deployment-service-typescript/index.ts new file mode 100644 index 00000000000..1b154f2d57d --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-eks-deployment-service-typescript/package.json b/themes/default/static/programs/awsx-ecr-eks-deployment-service-typescript/package.json new file mode 100644 index 00000000000..8c4c905596d --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-eks-deployment-service-typescript/tsconfig.json b/themes/default/static/programs/awsx-ecr-eks-deployment-service-typescript/tsconfig.json new file mode 100644 index 00000000000..11fc69af240 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-eks-deployment-service-yaml/Pulumi.yaml b/themes/default/static/programs/awsx-ecr-eks-deployment-service-yaml/Pulumi.yaml new file mode 100644 index 00000000000..403c1b5460e --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-eks-deployment-service-yaml/app/Dockerfile b/themes/default/static/programs/awsx-ecr-eks-deployment-service-yaml/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-image-csharp/Program.cs b/themes/default/static/programs/awsx-ecr-image-csharp/Program.cs new file mode 100644 index 00000000000..b341a8cd540 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-image-csharp/Pulumi.yaml b/themes/default/static/programs/awsx-ecr-image-csharp/Pulumi.yaml new file mode 100644 index 00000000000..1c5557c5434 --- /dev/null +++ b/themes/default/static/programs/awsx-ecr-image-csharp/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-ecr-image-csharp +runtime: dotnet diff --git a/themes/default/static/programs/awsx-ecr-image-csharp/app/Dockerfile b/themes/default/static/programs/awsx-ecr-image-csharp/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/programs/awsx-ecr-image-csharp/app/Dockerfile @@ -0,0 +1 @@ +FROM nginx \ No newline at end of file diff --git a/themes/default/static/programs/awsx-ecr-image-csharp/awsx-ecr-image-csharp.csproj b/themes/default/static/programs/awsx-ecr-image-csharp/awsx-ecr-image-csharp.csproj new file mode 100644 index 00000000000..ac10d4fba32 --- /dev/null +++ b/themes/default/static/programs/awsx-ecr-image-csharp/awsx-ecr-image-csharp.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + enable + + + + + + + + + diff --git a/themes/default/static/programs/awsx-ecr-image-go/Pulumi.yaml b/themes/default/static/programs/awsx-ecr-image-go/Pulumi.yaml new file mode 100644 index 00000000000..59864e0ee3a --- /dev/null +++ b/themes/default/static/programs/awsx-ecr-image-go/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-ecr-image-go +runtime: go diff --git a/themes/default/static/programs/awsx-ecr-image-go/app/Dockerfile b/themes/default/static/programs/awsx-ecr-image-go/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/programs/awsx-ecr-image-go/app/Dockerfile @@ -0,0 +1 @@ +FROM nginx \ No newline at end of file diff --git a/themes/default/static/programs/awsx-ecr-image-go/go.mod b/themes/default/static/programs/awsx-ecr-image-go/go.mod new file mode 100644 index 00000000000..49627583596 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-image-go/main.go b/themes/default/static/programs/awsx-ecr-image-go/main.go new file mode 100644 index 00000000000..180644a397e --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-image-java/Pulumi.yaml b/themes/default/static/programs/awsx-ecr-image-java/Pulumi.yaml new file mode 100644 index 00000000000..412ab73e107 --- /dev/null +++ b/themes/default/static/programs/awsx-ecr-image-java/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-ecr-image-java +runtime: java diff --git a/themes/default/static/programs/awsx-ecr-image-java/app/Dockerfile b/themes/default/static/programs/awsx-ecr-image-java/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/programs/awsx-ecr-image-java/app/Dockerfile @@ -0,0 +1 @@ +FROM nginx \ No newline at end of file diff --git a/themes/default/static/programs/awsx-ecr-image-java/pom.xml b/themes/default/static/programs/awsx-ecr-image-java/pom.xml new file mode 100644 index 00000000000..e55f2b3f12f --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-image-java/src/main/java/myproject/App.java b/themes/default/static/programs/awsx-ecr-image-java/src/main/java/myproject/App.java new file mode 100644 index 00000000000..05dbafa8db3 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-image-javascript/Pulumi.yaml b/themes/default/static/programs/awsx-ecr-image-javascript/Pulumi.yaml new file mode 100644 index 00000000000..58342d5761d --- /dev/null +++ b/themes/default/static/programs/awsx-ecr-image-javascript/Pulumi.yaml @@ -0,0 +1,5 @@ +name: awsx-ecr-image-javascript +runtime: + name: nodejs + options: + typescript: false diff --git a/themes/default/static/programs/awsx-ecr-image-javascript/app/Dockerfile b/themes/default/static/programs/awsx-ecr-image-javascript/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/programs/awsx-ecr-image-javascript/app/Dockerfile @@ -0,0 +1 @@ +FROM nginx \ No newline at end of file diff --git a/themes/default/static/programs/awsx-ecr-image-javascript/index.js b/themes/default/static/programs/awsx-ecr-image-javascript/index.js new file mode 100644 index 00000000000..f8923e92a16 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-image-javascript/package.json b/themes/default/static/programs/awsx-ecr-image-javascript/package.json new file mode 100644 index 00000000000..f1751a5ba3d --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-image-python/Pulumi.yaml b/themes/default/static/programs/awsx-ecr-image-python/Pulumi.yaml new file mode 100644 index 00000000000..4abe67ee372 --- /dev/null +++ b/themes/default/static/programs/awsx-ecr-image-python/Pulumi.yaml @@ -0,0 +1,5 @@ +name: awsx-ecr-image-python +runtime: + name: python + options: + virtualenv: venv diff --git a/themes/default/static/programs/awsx-ecr-image-python/__main__.py b/themes/default/static/programs/awsx-ecr-image-python/__main__.py new file mode 100644 index 00000000000..a418834a6b5 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-image-python/app/Dockerfile b/themes/default/static/programs/awsx-ecr-image-python/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/programs/awsx-ecr-image-python/app/Dockerfile @@ -0,0 +1 @@ +FROM nginx \ No newline at end of file diff --git a/themes/default/static/programs/awsx-ecr-image-python/requirements.txt b/themes/default/static/programs/awsx-ecr-image-python/requirements.txt new file mode 100644 index 00000000000..c8097039a51 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-image-typescript/Pulumi.yaml b/themes/default/static/programs/awsx-ecr-image-typescript/Pulumi.yaml new file mode 100644 index 00000000000..a954da14903 --- /dev/null +++ b/themes/default/static/programs/awsx-ecr-image-typescript/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-ecr-image-typescript +runtime: nodejs diff --git a/themes/default/static/programs/awsx-ecr-image-typescript/app/Dockerfile b/themes/default/static/programs/awsx-ecr-image-typescript/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/programs/awsx-ecr-image-typescript/app/Dockerfile @@ -0,0 +1 @@ +FROM nginx \ No newline at end of file diff --git a/themes/default/static/programs/awsx-ecr-image-typescript/index.ts b/themes/default/static/programs/awsx-ecr-image-typescript/index.ts new file mode 100644 index 00000000000..0952dd7ee81 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-image-typescript/package.json b/themes/default/static/programs/awsx-ecr-image-typescript/package.json new file mode 100644 index 00000000000..c0eba2ff6f3 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-image-typescript/tsconfig.json b/themes/default/static/programs/awsx-ecr-image-typescript/tsconfig.json new file mode 100644 index 00000000000..ab65afa6135 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-image-yaml/Pulumi.yaml b/themes/default/static/programs/awsx-ecr-image-yaml/Pulumi.yaml new file mode 100644 index 00000000000..b88b11e7ae2 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-ecr-image-yaml/app/Dockerfile b/themes/default/static/programs/awsx-ecr-image-yaml/app/Dockerfile new file mode 100644 index 00000000000..007148685f1 --- /dev/null +++ b/themes/default/static/programs/awsx-ecr-image-yaml/app/Dockerfile @@ -0,0 +1 @@ +FROM nginx \ No newline at end of file diff --git a/themes/default/static/programs/awsx-load-balanced-fargate-ecr-csharp/Program.cs b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-csharp/Program.cs new file mode 100644 index 00000000000..a37e3b45933 --- /dev/null +++ b/themes/default/static/programs/awsx-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 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 cluster = new Aws.Ecs.Cluster("cluster"); + + 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/programs/awsx-load-balanced-fargate-ecr-csharp/Pulumi.yaml b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-csharp/Pulumi.yaml new file mode 100644 index 00000000000..a7ef3c977db --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-csharp/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-load-balanced-fargate-ecr-csharp +runtime: dotnet diff --git a/themes/default/static/programs/awsx-load-balanced-fargate-ecr-csharp/awsx-load-balanced-fargate-ecr-csharp.csproj b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-csharp/awsx-load-balanced-fargate-ecr-csharp.csproj new file mode 100644 index 00000000000..57ad013e16d --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-csharp/awsx-load-balanced-fargate-ecr-csharp.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + enable + + + + + + + + + diff --git a/themes/default/static/programs/awsx-load-balanced-fargate-ecr-go/Pulumi.yaml b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-go/Pulumi.yaml new file mode 100644 index 00000000000..245130132d3 --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-go/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-load-balanced-fargate-ecr-go +runtime: go diff --git a/themes/default/static/programs/awsx-load-balanced-fargate-ecr-go/go.mod b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-go/go.mod new file mode 100644 index 00000000000..4b2afb26bd9 --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-go/go.mod @@ -0,0 +1,95 @@ +module awsx-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/programs/awsx-load-balanced-fargate-ecr-go/main.go b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-go/main.go new file mode 100644 index 00000000000..759e1f872d7 --- /dev/null +++ b/themes/default/static/programs/awsx-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/programs/awsx-load-balanced-fargate-ecr-java/Pulumi.yaml b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-java/Pulumi.yaml new file mode 100644 index 00000000000..1200a566098 --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-java/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-load-balanced-fargate-ecr-java +runtime: java diff --git a/themes/default/static/programs/awsx-load-balanced-fargate-ecr-java/pom.xml b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-java/pom.xml new file mode 100644 index 00000000000..31696537179 --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-java/pom.xml @@ -0,0 +1,97 @@ + + + 4.0.0 + + com.pulumi + awsx-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/programs/awsx-load-balanced-fargate-ecr-java/src/main/java/myproject/App.java b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-java/src/main/java/myproject/App.java new file mode 100644 index 00000000000..7c6007b2ed7 --- /dev/null +++ b/themes/default/static/programs/awsx-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/programs/awsx-load-balanced-fargate-ecr-javascript/Pulumi.yaml b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-javascript/Pulumi.yaml new file mode 100644 index 00000000000..3100dacecf4 --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-javascript/Pulumi.yaml @@ -0,0 +1,5 @@ +name: awsx-load-balanced-fargate-ecr-javascript +runtime: + name: nodejs + options: + typescript: false diff --git a/themes/default/static/programs/awsx-load-balanced-fargate-ecr-javascript/index.js b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-javascript/index.js new file mode 100644 index 00000000000..6b97d55962a --- /dev/null +++ b/themes/default/static/programs/awsx-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/programs/awsx-load-balanced-fargate-ecr-javascript/package.json b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-javascript/package.json new file mode 100644 index 00000000000..8fd05e7d9ca --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-javascript/package.json @@ -0,0 +1,12 @@ +{ + "name": "awsx-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/programs/awsx-load-balanced-fargate-ecr-python/Pulumi.yaml b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-python/Pulumi.yaml new file mode 100644 index 00000000000..0a0296b0875 --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-python/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-load-balanced-fargate-ecr-python +runtime: python diff --git a/themes/default/static/programs/awsx-load-balanced-fargate-ecr-python/__main__.py b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-python/__main__.py new file mode 100644 index 00000000000..1d887b457ad --- /dev/null +++ b/themes/default/static/programs/awsx-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/programs/awsx-load-balanced-fargate-ecr-python/requirements.txt b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-python/requirements.txt new file mode 100644 index 00000000000..961f30bc6eb --- /dev/null +++ b/themes/default/static/programs/awsx-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/programs/awsx-load-balanced-fargate-ecr-typescript/Pulumi.yaml b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-typescript/Pulumi.yaml new file mode 100644 index 00000000000..1c51cd5d8e3 --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-typescript/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-load-balanced-fargate-ecr-typescript +runtime: nodejs diff --git a/themes/default/static/programs/awsx-load-balanced-fargate-ecr-typescript/index.ts b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-typescript/index.ts new file mode 100644 index 00000000000..042b399d76b --- /dev/null +++ b/themes/default/static/programs/awsx-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/programs/awsx-load-balanced-fargate-ecr-typescript/package.json b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-typescript/package.json new file mode 100644 index 00000000000..1bf609c6755 --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-typescript/package.json @@ -0,0 +1,12 @@ +{ + "name": "awsx-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/programs/awsx-load-balanced-fargate-ecr-typescript/tsconfig.json b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-typescript/tsconfig.json new file mode 100644 index 00000000000..11fc69af240 --- /dev/null +++ b/themes/default/static/programs/awsx-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/programs/awsx-load-balanced-fargate-ecr-yaml/Pulumi.yaml b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-yaml/Pulumi.yaml new file mode 100644 index 00000000000..bb2e4d1e716 --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-ecr-yaml/Pulumi.yaml @@ -0,0 +1,40 @@ +name: awsx-load-balanced-fargate-ecr-yaml +runtime: yaml + +resources: + repo: + type: awsx:ecr:Repository + properties: + forceDelete: true + + image: + type: awsx:ecr:Image + properties: + repositoryUrl: ${repo.url} + context: ./app + platform: linux/amd64 + + cluster: + type: aws:ecs:Cluster + + lb: + type: awsx:lb:ApplicationLoadBalancer + + 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/programs/awsx-load-balanced-fargate-nginx-csharp/Program.cs b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-csharp/Program.cs new file mode 100644 index 00000000000..875fa0b8ccd --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-csharp/Program.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using Pulumi; +using Aws = Pulumi.Aws; +using Awsx = Pulumi.Awsx; + +return await Deployment.RunAsync(() => +{ + 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/programs/awsx-load-balanced-fargate-nginx-csharp/Pulumi.yaml b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-csharp/Pulumi.yaml new file mode 100644 index 00000000000..4d27aa7e835 --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-csharp/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-load-balanced-fargate-nginx-csharp +runtime: dotnet diff --git a/themes/default/static/programs/awsx-load-balanced-fargate-nginx-csharp/awsx-load-balanced-fargate-nginx-csharp.csproj b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-csharp/awsx-load-balanced-fargate-nginx-csharp.csproj new file mode 100644 index 00000000000..57ad013e16d --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-csharp/awsx-load-balanced-fargate-nginx-csharp.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + enable + + + + + + + + + diff --git a/themes/default/static/programs/awsx-load-balanced-fargate-nginx-go/Pulumi.yaml b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-go/Pulumi.yaml new file mode 100644 index 00000000000..eb00b2d8116 --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-go/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-load-balanced-fargate-nginx-go +runtime: go diff --git a/themes/default/static/programs/awsx-load-balanced-fargate-nginx-go/go.mod b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-go/go.mod new file mode 100644 index 00000000000..4b2afb26bd9 --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-go/go.mod @@ -0,0 +1,95 @@ +module awsx-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/programs/awsx-load-balanced-fargate-nginx-go/main.go b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-go/main.go new file mode 100644 index 00000000000..9de4ce74765 --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-go/main.go @@ -0,0 +1,49 @@ +package main + +import ( + "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ecs" + 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 { + 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/programs/awsx-load-balanced-fargate-nginx-java/Pulumi.yaml b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-java/Pulumi.yaml new file mode 100644 index 00000000000..70f3f3a7ce5 --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-java/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-load-balanced-fargate-nginx-yaml +runtime: java diff --git a/themes/default/static/programs/awsx-load-balanced-fargate-nginx-java/pom.xml b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-java/pom.xml new file mode 100644 index 00000000000..5b196ec5bb2 --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-java/pom.xml @@ -0,0 +1,97 @@ + + + 4.0.0 + + com.pulumi + awsx-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/programs/awsx-load-balanced-fargate-nginx-java/src/main/java/myproject/App.java b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-java/src/main/java/myproject/App.java new file mode 100644 index 00000000000..356bda12ebb --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-java/src/main/java/myproject/App.java @@ -0,0 +1,45 @@ +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) + .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/programs/awsx-load-balanced-fargate-nginx-javascript/Pulumi.yaml b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-javascript/Pulumi.yaml new file mode 100644 index 00000000000..4a28b7cff1e --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-javascript/Pulumi.yaml @@ -0,0 +1,5 @@ +name: awsx-load-balanced-fargate-nginx-javascript +runtime: + name: nodejs + options: + typescript: false diff --git a/themes/default/static/programs/awsx-load-balanced-fargate-nginx-javascript/index.js b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-javascript/index.js new file mode 100644 index 00000000000..0f0d0c1940d --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-javascript/index.js @@ -0,0 +1,28 @@ +"use strict"; +const pulumi = require("@pulumi/pulumi"); +const aws = require("@pulumi/aws"); +const awsx = require("@pulumi/awsx"); + +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/programs/awsx-load-balanced-fargate-nginx-javascript/package.json b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-javascript/package.json new file mode 100644 index 00000000000..4bcc28043d5 --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-javascript/package.json @@ -0,0 +1,12 @@ +{ + "name": "awsx-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/programs/awsx-load-balanced-fargate-nginx-python/Pulumi.yaml b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-python/Pulumi.yaml new file mode 100644 index 00000000000..df180fae58f --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-python/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-load-balanced-fargate-nginx-python +runtime: python diff --git a/themes/default/static/programs/awsx-load-balanced-fargate-nginx-python/__main__.py b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-python/__main__.py new file mode 100644 index 00000000000..385be5e741d --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-python/__main__.py @@ -0,0 +1,26 @@ +import pulumi +import pulumi_aws as aws +import pulumi_awsx as awsx + +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/programs/awsx-load-balanced-fargate-nginx-python/requirements.txt b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-python/requirements.txt new file mode 100644 index 00000000000..961f30bc6eb --- /dev/null +++ b/themes/default/static/programs/awsx-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/programs/awsx-load-balanced-fargate-nginx-typescript/Pulumi.yaml b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-typescript/Pulumi.yaml new file mode 100644 index 00000000000..d2937506550 --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-typescript/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-load-balanced-fargate-nginx-typescript +runtime: nodejs diff --git a/themes/default/static/programs/awsx-load-balanced-fargate-nginx-typescript/index.ts b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-typescript/index.ts new file mode 100644 index 00000000000..5fdf94b3add --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-typescript/index.ts @@ -0,0 +1,27 @@ +import * as pulumi from "@pulumi/pulumi"; +import * as aws from "@pulumi/aws"; +import * as awsx from "@pulumi/awsx"; + +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/programs/awsx-load-balanced-fargate-nginx-typescript/package.json b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-typescript/package.json new file mode 100644 index 00000000000..78c2fe1d013 --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-typescript/package.json @@ -0,0 +1,12 @@ +{ + "name": "awsx-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/programs/awsx-load-balanced-fargate-nginx-typescript/tsconfig.json b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-typescript/tsconfig.json new file mode 100644 index 00000000000..11fc69af240 --- /dev/null +++ b/themes/default/static/programs/awsx-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/programs/awsx-load-balanced-fargate-nginx-yaml/Pulumi.yaml b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-yaml/Pulumi.yaml new file mode 100644 index 00000000000..36992b22062 --- /dev/null +++ b/themes/default/static/programs/awsx-load-balanced-fargate-nginx-yaml/Pulumi.yaml @@ -0,0 +1,24 @@ +name: awsx-load-balanced-fargate-nginx-yaml +runtime: yaml +resources: + 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} diff --git a/themes/default/static/programs/awsx-vpc-fargate-service-csharp/Program.cs b/themes/default/static/programs/awsx-vpc-fargate-service-csharp/Program.cs new file mode 100644 index 00000000000..6f89035a729 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-vpc-fargate-service-csharp/Pulumi.yaml b/themes/default/static/programs/awsx-vpc-fargate-service-csharp/Pulumi.yaml new file mode 100644 index 00000000000..d38a7abbff2 --- /dev/null +++ b/themes/default/static/programs/awsx-vpc-fargate-service-csharp/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-vpc-fargate-service-csharp +runtime: dotnet diff --git a/themes/default/static/programs/awsx-vpc-fargate-service-csharp/awsx-vpc-fargate-service-csharp.csproj b/themes/default/static/programs/awsx-vpc-fargate-service-csharp/awsx-vpc-fargate-service-csharp.csproj new file mode 100644 index 00000000000..57ad013e16d --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-vpc-fargate-service-go/Pulumi.yaml b/themes/default/static/programs/awsx-vpc-fargate-service-go/Pulumi.yaml new file mode 100644 index 00000000000..2af45806a56 --- /dev/null +++ b/themes/default/static/programs/awsx-vpc-fargate-service-go/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-vpc-fargate-service-go +runtime: go diff --git a/themes/default/static/programs/awsx-vpc-fargate-service-go/go.mod b/themes/default/static/programs/awsx-vpc-fargate-service-go/go.mod new file mode 100644 index 00000000000..161501c8615 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-vpc-fargate-service-go/main.go b/themes/default/static/programs/awsx-vpc-fargate-service-go/main.go new file mode 100644 index 00000000000..7f3b4cd3845 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-vpc-fargate-service-java/Pulumi.yaml b/themes/default/static/programs/awsx-vpc-fargate-service-java/Pulumi.yaml new file mode 100644 index 00000000000..364368f4e14 --- /dev/null +++ b/themes/default/static/programs/awsx-vpc-fargate-service-java/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-vpc-fargate-service-java +runtime: java diff --git a/themes/default/static/programs/awsx-vpc-fargate-service-java/pom.xml b/themes/default/static/programs/awsx-vpc-fargate-service-java/pom.xml new file mode 100644 index 00000000000..05a393f543d --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-vpc-fargate-service-java/src/main/java/myproject/App.java b/themes/default/static/programs/awsx-vpc-fargate-service-java/src/main/java/myproject/App.java new file mode 100644 index 00000000000..473dea7b7a1 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-vpc-fargate-service-javascript/Pulumi.yaml b/themes/default/static/programs/awsx-vpc-fargate-service-javascript/Pulumi.yaml new file mode 100644 index 00000000000..b3af8730758 --- /dev/null +++ b/themes/default/static/programs/awsx-vpc-fargate-service-javascript/Pulumi.yaml @@ -0,0 +1,5 @@ +name: awsx-vpc-fargate-service-javascript +runtime: + name: nodejs + options: + typescript: false diff --git a/themes/default/static/programs/awsx-vpc-fargate-service-javascript/index.js b/themes/default/static/programs/awsx-vpc-fargate-service-javascript/index.js new file mode 100644 index 00000000000..ac576cd6db6 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-vpc-fargate-service-javascript/package.json b/themes/default/static/programs/awsx-vpc-fargate-service-javascript/package.json new file mode 100644 index 00000000000..f5b9db80fd4 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-vpc-fargate-service-python/Pulumi.yaml b/themes/default/static/programs/awsx-vpc-fargate-service-python/Pulumi.yaml new file mode 100644 index 00000000000..13aa9494567 --- /dev/null +++ b/themes/default/static/programs/awsx-vpc-fargate-service-python/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-vpc-fargate-service-python +runtime: python diff --git a/themes/default/static/programs/awsx-vpc-fargate-service-python/__main__.py b/themes/default/static/programs/awsx-vpc-fargate-service-python/__main__.py new file mode 100644 index 00000000000..d66d407586d --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-vpc-fargate-service-python/requirements.txt b/themes/default/static/programs/awsx-vpc-fargate-service-python/requirements.txt new file mode 100644 index 00000000000..961f30bc6eb --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-vpc-fargate-service-typescript/Pulumi.yaml b/themes/default/static/programs/awsx-vpc-fargate-service-typescript/Pulumi.yaml new file mode 100644 index 00000000000..83334cd7471 --- /dev/null +++ b/themes/default/static/programs/awsx-vpc-fargate-service-typescript/Pulumi.yaml @@ -0,0 +1,2 @@ +name: awsx-vpc-fargate-service-typescript +runtime: nodejs diff --git a/themes/default/static/programs/awsx-vpc-fargate-service-typescript/index.ts b/themes/default/static/programs/awsx-vpc-fargate-service-typescript/index.ts new file mode 100644 index 00000000000..03e118c45ce --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-vpc-fargate-service-typescript/package.json b/themes/default/static/programs/awsx-vpc-fargate-service-typescript/package.json new file mode 100644 index 00000000000..f2cdb537458 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-vpc-fargate-service-typescript/tsconfig.json b/themes/default/static/programs/awsx-vpc-fargate-service-typescript/tsconfig.json new file mode 100644 index 00000000000..11fc69af240 --- /dev/null +++ b/themes/default/static/programs/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/programs/awsx-vpc-fargate-service-yaml/Pulumi.yaml b/themes/default/static/programs/awsx-vpc-fargate-service-yaml/Pulumi.yaml new file mode 100644 index 00000000000..cf7d9d787c7 --- /dev/null +++ b/themes/default/static/programs/awsx-vpc-fargate-service-yaml/Pulumi.yaml @@ -0,0 +1,35 @@ +name: awsx-vpc-fargate-service-yaml +runtime: 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: + name: my-service + image: nginx:latest + cpu: 128 + memory: 512 + essential: true