diff --git a/aws-ts-lambda-efs/index.ts b/aws-ts-lambda-efs/index.ts index 9927ba4a5..a4b61a865 100644 --- a/aws-ts-lambda-efs/index.ts +++ b/aws-ts-lambda-efs/index.ts @@ -1,7 +1,6 @@ // Copyright 2016-2019, Pulumi Corporation. All rights reserved. import * as aws from "@pulumi/aws"; -import * as apigateway from "@pulumi/aws-apigateway"; import * as awsx from "@pulumi/awsx"; import * as cp from "child_process"; import * as fs from "fs"; @@ -9,20 +8,19 @@ import * as fs from "fs"; export = async () => { // VPC - const vpc = new awsx.ec2.Vpc("vpc", {}); // subnets default to one private, one public + const vpc = new awsx.ec2.Vpc("vpc", { subnets: [{ type: "private" }, { type: "public" }] }); + const subnetIds = await vpc.publicSubnetIds; // EFS const filesystem = new aws.efs.FileSystem("filesystem"); - const targets: aws.efs.MountTarget[] = []; - vpc.publicSubnetIds.apply(ids => { - for (let i = 0; i < ids.length; i++) { - targets.push(new aws.efs.MountTarget(`fs-mount-${i}`, { - fileSystemId: filesystem.id, - subnetId: ids[i], - securityGroups: [vpc.vpc.defaultSecurityGroupId], - })); - } - }); + const targets = []; + for (let i = 0; i < subnetIds.length; i++) { + targets.push(new aws.efs.MountTarget(`fs-mount-${i}`, { + fileSystemId: filesystem.id, + subnetId: subnetIds[i], + securityGroups: [vpc.vpc.defaultSecurityGroupId], + })); + } const ap = new aws.efs.AccessPoint("ap", { fileSystemId: filesystem.id, posixUser: { uid: 1000, gid: 1000 }, @@ -30,7 +28,7 @@ export = async () => { }, { dependsOn: targets }); // Lambda - function efsvpcCallback(name: string, f: aws.lambda.Callback) { + function efsvpcCallback(name: string, f: aws.lambda.Callback) { return new aws.lambda.CallbackFunction(name, { policies: [aws.iam.ManagedPolicy.AWSLambdaVPCAccessExecutionRole, aws.iam.ManagedPolicy.LambdaFullAccess], vpcConfig: { @@ -43,13 +41,12 @@ export = async () => { } // API Gateway - const api = new apigateway.RestAPI("api", { + const api = new awsx.apigateway.API("api", { routes: [ { method: "GET", path: "/files/{filename+}", eventHandler: efsvpcCallback("getHandler", async (ev, ctx) => { try { - const event = ev; - const f = "/mnt/storage/" + event.pathParameters!.filename; + const f = "/mnt/storage/" + ev.pathParameters!.filename; const data = fs.readFileSync(f); return { statusCode: 200, @@ -63,9 +60,8 @@ export = async () => { { method: "POST", path: "/files/{filename+}", eventHandler: efsvpcCallback("uploadHandler", async (ev, ctx) => { try { - const event = ev; - const f = "/mnt/storage/" + event.pathParameters!.filename; - const data = Buffer.from(event.body!, "base64"); + const f = "/mnt/storage/" + ev.pathParameters!.filename; + const data = new Buffer(ev.body!, "base64"); fs.writeFileSync(f, data); return { statusCode: 200, @@ -78,8 +74,7 @@ export = async () => { }, { method: "POST", path: "/", eventHandler: efsvpcCallback("execHandler", async (ev, ctx) => { - const event = ev; - const cmd = Buffer.from(event.body!, "base64").toString(); + const cmd = new Buffer(ev.body!, "base64").toString(); const buf = cp.execSync(cmd); return { statusCode: 200, @@ -91,7 +86,7 @@ export = async () => { }); // ECS Cluster - const cluster = new aws.ecs.Cluster("cluster"); + const cluster = new awsx.ecs.Cluster("cluster", { vpc: vpc }); const efsVolumeConfiguration: aws.types.input.ecs.TaskDefinitionVolumeEfsVolumeConfiguration = { fileSystemId: filesystem.id, authorizationConfig: { accessPointId: ap.id }, @@ -101,10 +96,9 @@ export = async () => { // Fargate Service const nginx = new awsx.ecs.FargateService("nginx", { - cluster: cluster.arn, + cluster: cluster, taskDefinitionArgs: { container: { - name: "nginx", image: "nginx", memory: 128, portMappings: [{ containerPort: 80, hostPort: 80, protocol: "tcp" }], @@ -112,10 +106,8 @@ export = async () => { }, volumes: [{ name: "efs", efsVolumeConfiguration }], }, - networkConfiguration: { - subnets: vpc.publicSubnetIds, - securityGroups: [vpc.vpc.defaultSecurityGroupId], - }, + securityGroups: [vpc.vpc.defaultSecurityGroupId, ...cluster.securityGroups], + subnets: vpc.publicSubnetIds, platformVersion: "1.4.0", }); diff --git a/aws-ts-lambda-efs/package.json b/aws-ts-lambda-efs/package.json index 267185d9c..04574108e 100644 --- a/aws-ts-lambda-efs/package.json +++ b/aws-ts-lambda-efs/package.json @@ -2,12 +2,8 @@ "name": "aws-ts-lambda-efs", "version": "0.1.0", "dependencies": { - "@pulumi/aws": "^6.0.0", - "@pulumi/aws-apigateway": "1.1.0-alpha.3", - "@pulumi/awsx": "2.0.0-beta.3", + "@pulumi/aws": "^5.0.0", + "@pulumi/awsx": "^0.40.0", "@pulumi/pulumi": "^3.0.0" - }, - "devDependencies": { - "typescript": "^4.6.2" } } diff --git a/aws-ts-pulumi-webhooks/package.json b/aws-ts-pulumi-webhooks/package.json index d34ac041d..82e9dbe52 100644 --- a/aws-ts-pulumi-webhooks/package.json +++ b/aws-ts-pulumi-webhooks/package.json @@ -1,12 +1,11 @@ { "name": "typescript", "devDependencies": { - "@types/node": "^18.0.0", - "typescript": "^4.6.2" + "@types/node": "^8.0.0" }, "dependencies": { - "@pulumi/aws": "^6.0.0", - "@pulumi/awsx": "2.0.0-beta.3", + "@pulumi/aws": "^5.0.0", + "@pulumi/awsx": "^0.40.0", "@pulumi/pulumi": "^3.0.0", "@slack/webhook": "^5.0.3" } diff --git a/aws-ts-thumbnailer/index.ts b/aws-ts-thumbnailer/index.ts index a0b057838..d8ca347dc 100644 --- a/aws-ts-thumbnailer/index.ts +++ b/aws-ts-thumbnailer/index.ts @@ -12,7 +12,7 @@ const bucket = new aws.s3.Bucket("bucket"); // Export the bucket name. export const bucketName = bucket.id; -// Create a repository for the FFMPEG image. +// Create a repository for hte FFMPEG image. const repo = new awsx.ecr.Repository("repo", { forceDelete: true, }); @@ -20,7 +20,7 @@ const repo = new awsx.ecr.Repository("repo", { // A task which runs a containerized FFMPEG job to extract a thumbnail image. const ffmpegThumbnailTask = new awsx.classic.ecs.FargateTaskDefinition("ffmpegThumbTask", { container: { - image: new awsx.ecr.Image("ffmpegThumbTask", { repositoryUrl: repo.url, context: "./docker-ffmpeg-thumb" }).imageUri, + image: new awsx.ecr.Image("ffmpegThumbTask", { repositoryUrl: repo.url, path: "./docker-ffmpeg-thumb" }).imageUri, memoryReservation: 512, }, }); diff --git a/aws-ts-thumbnailer/package.json b/aws-ts-thumbnailer/package.json index 02c5c5e1e..8750f696a 100755 --- a/aws-ts-thumbnailer/package.json +++ b/aws-ts-thumbnailer/package.json @@ -3,8 +3,8 @@ "version": "0.1.0", "main": "index.ts", "dependencies": { - "@pulumi/aws": "^6.0.0", - "@pulumi/awsx": "2.0.0-beta.3", + "@pulumi/aws": "^5.30.0", + "@pulumi/awsx": "^1.0.2", "@pulumi/pulumi": "^3.55.0" } }