Skip to content

Commit

Permalink
A few more test fixes (pulumi#1344)
Browse files Browse the repository at this point in the history
* Relax AMI filter arg
* Fix duplicate project names
* Use valid droplet sizes
* Update the AWS JS & TS container examples
* Add forceDestroy options
* Fix Kubernetes version inputs
* Quote Azure filter
* Upgrade aws-ts-airflow
* Reduce droplet count
* Restore .NET version for webserver example
* Skip aws-ts-airflow
* Fix aws-ts-hello-fargate
* Tolerate changes
* More duplicate project names
* Fix config references
* Drop the DO node count to 2
* Fix project name
* Fix aws-ts-thumbnailer
* Fix AMI filter queries
* Add more allow-changes
  • Loading branch information
cnunciato committed Feb 17, 2023
1 parent a03e018 commit cf8b887
Show file tree
Hide file tree
Showing 35 changed files with 183 additions and 117 deletions.
2 changes: 1 addition & 1 deletion aws-cs-assume-role/assume-role/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name: assume-role
name: aws-cs-assume-role
runtime: dotnet
description: Demonstrate use of AWS AssumeRole Functionality in C#
2 changes: 1 addition & 1 deletion aws-cs-assume-role/create-role/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name: create-role
name: aws-cs-create-role
runtime: dotnet
description: Demonstrate use of AWS AssumeRole Functionality in C#
2 changes: 1 addition & 1 deletion aws-go-assume-role/assume-role/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name: assume-role
name: aws-go-assume-role
runtime: go
description: Demonstrate use of AWS AssumeRole Functionality
2 changes: 1 addition & 1 deletion aws-go-assume-role/create-role/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name: create-role
name: aws-go-create-role
runtime: go
description: Demonstrate use of AWS AssumeRole Functionality
2 changes: 1 addition & 1 deletion aws-js-containers/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: container-quickstart
name: aws-js-containers
description: NGINX container example
runtime: nodejs
template:
Expand Down
3 changes: 1 addition & 2 deletions aws-js-containers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ Use the [`pulumi logs`](https://www.pulumi.com/docs/reference/cli/pulumi_logs/)

```
$ pulumi logs --follow
Collecting logs for stack container-quickstart-dev since 2018-05-22T14:25:46.000-07:00.
Collecting logs for stack aws-js-containers-dev since 2018-05-22T14:25:46.000-07:00.
2018-05-22T15:33:22.057-07:00[ pulumi-nginx] 172.31.13.248 - - [22/May/2018:22:33:22 +0000] "GET / HTTP/1.1" 200 189 "-" "curl/7.54.0" "-"
```

## Clean Up

To clean up resources, run [`pulumi destroy`](https://www.pulumi.com/docs/reference/cli/pulumi_destroy/) to avoid incurring any costs. Select `yes` on the confirmation prompt so Pulumi will remove all of the resources that you've created. To delete the stack itself, run [`pulumi stack rm`](https://www.pulumi.com/docs/reference/cli/pulumi_stack_rm/). Note that this command deletes all deployment history from the Pulumi Console, unless you've explicitly [chosen a different backend](https://www.pulumi.com/docs/intro/concepts/state/) for storing your infrastructure state.

51 changes: 35 additions & 16 deletions aws-js-containers/index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,43 @@
const pulumi = require("@pulumi/pulumi");
// Copyright 2016-2023, Pulumi Corporation. All rights reserved.

const aws = require("@pulumi/aws");
const awsx = require("@pulumi/awsx");
const pulumi = require("@pulumi/pulumi");

// An ECS cluster to deploy into.
const cluster = new aws.ecs.Cluster("cluster", {});

// Create an elastic network listener to listen for requests and route them to the container.
// See https://docs.aws.amazon.com/elasticloadbalancing/latest/network/introduction.html
// for more details.
let listener = new awsx.elasticloadbalancingv2.NetworkListener("nginx", { port: 80 });
// An ALB to serve the container endpoint to the internet.
const loadbalancer = new awsx.lb.ApplicationLoadBalancer("loadbalancer", {});

// An ECR repository to store our application's container image.
const repo = new awsx.ecr.Repository("repo", {
forceDelete: true,
});

// Build and publish our application's container image from ./app to the ECR repository.
const image = new awsx.ecr.Image("image", {
repositoryUrl: repo.url,
path: "./app",
});

// Define the service to run. We pass in the listener to hook up the network load balancer
// to the containers the service will launch.
let service = new awsx.ecs.FargateService("nginx", {
desiredCount: 2,
// Deploy an ECS Service on Fargate to host the application container.
const service = new awsx.ecs.FargateService("service", {
cluster: cluster.arn,
assignPublicIp: true,
taskDefinitionArgs: {
containers: {
nginx: {
image: awsx.ecs.Image.fromPath("nginx", "./app"),
memory: 512,
portMappings: [listener],
},
container: {
image: image.imageUri,
cpu: 128,
memory: 512,
essential: true,
portMappings: [{
containerPort: 80,
targetGroup: loadbalancer.defaultTargetGroup,
}],
},
},
});

exports.frontendURL = pulumi.interpolate `http:https://${listener.endpoint.hostname}/`;
// The URL at which the container's HTTP endpoint will be available.
exports.frontendURL = pulumi.interpolate`http:https://${loadbalancer.loadBalancer.dnsName}`;
8 changes: 4 additions & 4 deletions aws-js-containers/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "container-quickstart",
"name": "aws-js-containers",
"main": "index.js",
"dependencies": {
"@pulumi/aws": "^5.0.0",
"@pulumi/awsx": "^0.40.0",
"@pulumi/pulumi": "^3.0.0"
"@pulumi/aws": "^5.29.1",
"@pulumi/awsx": "^1.0.2",
"@pulumi/pulumi": "^3.55.0"
}
}
2 changes: 1 addition & 1 deletion aws-py-assume-role/assume-role/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: assume-role
name: aws-py-assume-role
runtime:
name: python
options:
Expand Down
2 changes: 1 addition & 1 deletion aws-py-assume-role/create-role/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: create-role
name: aws-py-create-role
runtime:
name: python
options:
Expand Down
2 changes: 1 addition & 1 deletion aws-py-ec2-provisioners/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def decode_key(key):
most_recent=True,
filters=[aws.ec2.GetAmiFilterArgs(
name='name',
values=['amzn2-ami-hvm-2.0.????????-x86_64-gp2'],
values=['amzn2-ami-hvm-*-x86_64-gp2'],
)],
)

Expand Down
26 changes: 15 additions & 11 deletions aws-ts-airflow/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import * as pulumi from "@pulumi/pulumi";
const config = new pulumi.Config("airflow");
const dbPassword = config.requireSecret("dbPassword");

const vpc = awsx.ec2.Vpc.getDefault();
const vpc = awsx.classic.ec2.Vpc.getDefault();

// Create a basic cluster and autoscaling group
const cluster = new awsx.ecs.Cluster("airflow", { vpc });
const cluster = new awsx.classic.ecs.Cluster("airflow", { vpc });
const autoScalingGroup = cluster.createAutoScalingGroup("airflow", {
subnetIds: vpc.publicSubnetIds,
templateParameters: {
Expand Down Expand Up @@ -65,27 +65,31 @@ const environment = hosts.apply(([postgresHost, redisHost]) => [
{ name: "EXECUTOR", value: "Celery" },
]);

const airflowControllerListener = new awsx.elasticloadbalancingv2.ApplicationListener("airflowcontroller", {
const airflowControllerListener = new awsx.classic.lb.ApplicationListener("airflowcontroller", {
external: true,
port: 8080,
protocol: "HTTP",
});

const airflowController = new awsx.ecs.EC2Service("airflowcontroller", {
const repo = new awsx.ecr.Repository("repo", {
forceDelete: true,
});

const airflowController = new awsx.classic.ecs.EC2Service("airflowcontroller", {
cluster,
desiredCount: 1,
taskDefinitionArgs: {
containers: {
"webserver": {
image: awsx.ecs.Image.fromPath("webserver", "./airflow-container"),
image: new awsx.ecr.Image("webserver", { repositoryUrl: repo.url, path: "./airflow-container" }).imageUri,
portMappings: [airflowControllerListener],
environment: environment,
command: [ "webserver" ],
memory: 128,
},

"scheduler": {
image: awsx.ecs.Image.fromPath("scheduler", "./airflow-container"),
image: new awsx.ecr.Image("scheduler", { repositoryUrl: repo.url, path: "./airflow-container" }).imageUri,
environment: environment,
command: [ "scheduler" ],
memory: 128,
Expand All @@ -94,20 +98,20 @@ const airflowController = new awsx.ecs.EC2Service("airflowcontroller", {
},
});

const airflowerListener = new awsx.elasticloadbalancingv2.ApplicationListener("airflower", {
const airflowerListener = new awsx.classic.lb.ApplicationListener("airflower", {
port: 5555,
external: true,
protocol: "HTTP",
});

const airflower = new awsx.ecs.EC2Service("airflower", {
const airflower = new awsx.classic.ecs.EC2Service("airflower", {
cluster,
taskDefinitionArgs: {
containers: {
// If the container is named "flower", we create environment variables that start
// with `FLOWER_` and Flower tries and fails to parse them as configuration.
"notflower": {
image: awsx.ecs.Image.fromPath("notflower", "./airflow-container"),
image: new awsx.ecr.Image("notflower", { repositoryUrl: repo.url, path: "./airflow-container" }).imageUri,
portMappings: [airflowerListener],
environment: environment,
command: [ "flower" ],
Expand All @@ -117,13 +121,13 @@ const airflower = new awsx.ecs.EC2Service("airflower", {
},
});

const airflowWorkers = new awsx.ecs.EC2Service("airflowworkers", {
const airflowWorkers = new awsx.classic.ecs.EC2Service("airflowworkers", {
cluster,
desiredCount: 3,
taskDefinitionArgs: {
containers: {
"worker": {
image: awsx.ecs.Image.fromPath("worker", "./airflow-container"),
image: new awsx.ecr.Image("worker", { repositoryUrl: repo.url, path: "./airflow-container" }).imageUri,
environment: environment,
command: [ "worker" ],
memory: 1024,
Expand Down
8 changes: 4 additions & 4 deletions aws-ts-airflow/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "airflow",
"devDependencies": {
"@types/node": "^8.0.0"
"@types/node": "^18.13.0"
},
"dependencies": {
"@pulumi/aws": "^5.0.0",
"@pulumi/awsx": "^0.40.0",
"@pulumi/pulumi": "^3.0.0"
"@pulumi/aws": "^5.29.1",
"@pulumi/awsx": "^1.0.2",
"@pulumi/pulumi": "^3.55.0"
}
}
2 changes: 1 addition & 1 deletion aws-ts-assume-role/assume-role/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name: assume-role
name: aws-ts-assume-role
runtime: nodejs
description: Demonstrate use of AWS AssumeRole Functionality
2 changes: 1 addition & 1 deletion aws-ts-assume-role/create-role/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name: create-role
name: aws-ts-create-role
runtime: nodejs
description: Demonstrate use of AWS AssumeRole Functionality
2 changes: 1 addition & 1 deletion aws-ts-containers/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: container-quickstart
name: aws-ts-containers
description: NGINX container example
runtime: nodejs
template:
Expand Down
3 changes: 1 addition & 2 deletions aws-ts-containers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ with `***`.

```
$ pulumi logs --follow
Collecting logs for stack container-quickstart-dev since 2018-05-22T14:25:46.000-07:00.
Collecting logs for stack aws-ts-containers-dev since 2018-05-22T14:25:46.000-07:00.
2018-05-22T15:33:22.057-07:00[ pulumi-nginx] 172.31.13.248 - - [22/May/2018:22:33:22 +0000] "GET / HTTP/1.1" 200 189 "-" "curl/7.54.0" "-"
```

## Clean up

To clean up resources, run `pulumi destroy` and answer the confirmation question at the prompt.

49 changes: 33 additions & 16 deletions aws-ts-containers/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,43 @@
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.
// Copyright 2016-2023, Pulumi Corporation. All rights reserved.

import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
import * as pulumi from "@pulumi/pulumi";

// Create an elastic network listener to listen for requests and route them to the container.
// See https://docs.aws.amazon.com/elasticloadbalancing/latest/network/introduction.html
// for more details.
const listener = new awsx.elasticloadbalancingv2.NetworkListener("nginx", { port: 80 });
// An ECS cluster to deploy into.
const cluster = new aws.ecs.Cluster("cluster", {});

// Define the service to run. We pass in the listener to hook up the network load balancer
// to the containers the service will launch.
const service = new awsx.ecs.FargateService("nginx", {
desiredCount: 3,
// An ALB to serve the container endpoint to the internet.
const loadbalancer = new awsx.lb.ApplicationLoadBalancer("loadbalancer", {});

// An ECR repository to store our application's container image.
const repo = new awsx.ecr.Repository("repo", {
forceDelete: true,
});

// Build and publish our application's container image from ./app to the ECR repository.
const image = new awsx.ecr.Image("image", {
repositoryUrl: repo.url,
path: "./app",
});

// Deploy an ECS Service on Fargate to host the application container.
const service = new awsx.ecs.FargateService("service", {
cluster: cluster.arn,
assignPublicIp: true,
taskDefinitionArgs: {
containers: {
nginx: {
image: awsx.ecs.Image.fromPath("nginx", "./app"),
memory: 512,
portMappings: [listener],
},
container: {
image: image.imageUri,
cpu: 128,
memory: 512,
essential: true,
portMappings: [{
containerPort: 80,
targetGroup: loadbalancer.defaultTargetGroup,
}],
},
},
});

export let frontendURL = pulumi.interpolate `http:https://${listener.endpoint.hostname}/`;
// The URL at which the container's HTTP endpoint will be available.
export const frontendURL = pulumi.interpolate`http:https://${loadbalancer.loadBalancer.dnsName}`;
8 changes: 4 additions & 4 deletions aws-ts-containers/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "container-quickstart",
"name": "aws-ts-containers",
"main": "index.js",
"dependencies": {
"@pulumi/aws": "^5.0.0",
"@pulumi/awsx": "^0.40.0",
"@pulumi/pulumi": "^3.0.0"
"@pulumi/aws": "^5.29.1",
"@pulumi/awsx": "^1.0.2",
"@pulumi/pulumi": "^3.55.0"
}
}
2 changes: 1 addition & 1 deletion aws-ts-ec2-provisioners/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const amiId = aws.ec2.getAmi({
mostRecent: true,
filters: [{
name: "name",
values: ["amzn2-ami-hvm-2.0.????????-x86_64-gp2"],
values: ["amzn2-ami-hvm-*-x86_64-gp2"],
}],
}, { async: true }).then(ami => ami.id);

Expand Down
27 changes: 16 additions & 11 deletions aws-ts-hello-fargate/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.
// Copyright 2016-2023, Pulumi Corporation. All rights reserved.

import * as awsx from "@pulumi/awsx";

// Step 1: Create an ECS Fargate cluster.
const cluster = new awsx.ecs.Cluster("cluster");
// Create an ECS Fargate cluster.
const cluster = new awsx.classic.ecs.Cluster("cluster");

// Step 2: Define the Networking for our service.
const alb = new awsx.elasticloadbalancingv2.ApplicationLoadBalancer(
// Define the Networking for our service.
const alb = new awsx.classic.lb.ApplicationLoadBalancer(
"net-lb", { external: true, securityGroups: cluster.securityGroups });
const web = alb.createListener("web", { port: 80, external: true });

// Step 3: Build and publish a Docker image to a private ECR registry.
const img = awsx.ecs.Image.fromPath("app-img", "./app");
// Create a repository for container images.
const repo = new awsx.ecr.Repository("repo", {
forceDelete: true,
});

// Build and publish a Docker image to a private ECR registry.
const img = new awsx.ecr.Image("app-img", { repositoryUrl: repo.url, path: "./app" });

// Step 4: Create a Fargate service task that can scale out.
const appService = new awsx.ecs.FargateService("app-svc", {
// Create a Fargate service task that can scale out.
const appService = new awsx.classic.ecs.FargateService("app-svc", {
cluster,
taskDefinitionArgs: {
container: {
image: img,
image: img.imageUri,
cpu: 102 /*10% of 1024*/,
memory: 50 /*MB*/,
portMappings: [ web ],
Expand All @@ -27,5 +32,5 @@ const appService = new awsx.ecs.FargateService("app-svc", {
desiredCount: 5,
});

// Step 5: Export the Internet address for the service.
// Export the Internet address for the service.
export const url = web.endpoint.hostname;
Loading

0 comments on commit cf8b887

Please sign in to comment.