Skip to content

Commit

Permalink
Some text fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cnunciato committed Jul 3, 2024
1 parent ce94281 commit 12ddc69
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
46 changes: 44 additions & 2 deletions aws-ts-lambda-efs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,59 @@ export = async () => {
rootDirectory: { path: "/www", creationInfo: { ownerGid: 1000, ownerUid: 1000, permissions: "755" } },
}, { dependsOn: targets });

// Function to create a delay using setTimeout and a Promise
function delay(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}

// Create a Pulumi component resource that waits for 10 seconds
class WaitResource extends pulumi.ComponentResource {
constructor(name: string, args = {}, opts?: pulumi.ResourceOptions) {
super("custom:resource:WaitResource", name, args, opts);

// Create a delay of 10 seconds
const wait = delay(60000).then(() => {
this.registerOutputs();
});

// Register the wait promise as an output
this.registerOutputs({ wait });
}
}

// Instantiate the wait resource
const waitResource = new WaitResource("waitResource", {}, { dependsOn: targets });

const lambdaRole = new aws.iam.Role("lambda-role", {
assumeRolePolicy: JSON.stringify({
Version: "2012-10-17",
Statement: [{
Action: "sts:AssumeRole",
Principal: {
Service: "lambda.amazonaws.com",
},
Effect: "Allow",
}],
}),

managedPolicyArns: [
aws.iam.ManagedPolicy.AWSLambdaVPCAccessExecutionRole,
aws.iam.ManagedPolicy.LambdaFullAccess,
],
});

// Lambda
function efsvpcCallback(name: string, f: aws.lambda.Callback<APIGatewayProxyEvent, APIGatewayProxyResult>) {
return new aws.lambda.CallbackFunction(name, {
policies: [aws.iam.ManagedPolicy.AWSLambdaVPCAccessExecutionRole, aws.iam.ManagedPolicy.LambdaFullAccess],
role: lambdaRole,

vpcConfig: {
subnetIds: vpc.privateSubnetIds,
securityGroupIds: [vpc.vpc.defaultSecurityGroupId],
},
fileSystemConfig: { arn: ap.arn, localMountPath: "/mnt/storage" },
callback: f,
}, {dependsOn: targets});
}, {dependsOn: [waitResource]});
}

// API Gateway
Expand Down
6 changes: 6 additions & 0 deletions gcp-ts-cloudrun/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const myImage = new docker.Image(imageName, {
imageName: pulumi.interpolate`gcr.io/${gcp.config.project}/${imageName}:v1.0.0`,
build: {
context: "./app",
platform: "linux/amd64",
},
});

Expand All @@ -65,6 +66,11 @@ const rubyService = new gcp.cloudrun.Service("ruby", {
memory: "1Gi",
},
},
ports: [
{
containerPort: 8080,
},
],
}],
containerConcurrency: 50,
},
Expand Down
2 changes: 1 addition & 1 deletion gcp-ts-cloudrun/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"@types/node": "^12.0.0"
},
"dependencies": {
"@pulumi/docker": "^3.0.0",
"@pulumi/docker": "^4.0.0",
"@pulumi/gcp": "^7.0.0",
"@pulumi/pulumi": "^3.0.0"
}
Expand Down

0 comments on commit 12ddc69

Please sign in to comment.