Last active
July 18, 2025 17:52
-
-
Save cnunciato/a7aef242dbd1195255b5920d54264b70 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as pulumi from "@pulumi/pulumi"; | |
| import * as aws from "@pulumi/aws"; | |
| import * as apigateway from "@pulumi/aws-apigateway"; | |
| import * as fs from "fs"; | |
| const fn = new aws.lambda.CallbackFunction("fn", { | |
| callback: async (ev, ctx) => { | |
| return { | |
| statusCode: 200, | |
| body: new Date().toISOString(), | |
| }; | |
| } | |
| }) | |
| const api = new apigateway.RestAPI("api", { | |
| routes: [ | |
| { path: "/", localPath: "www"}, | |
| { path: "/date", method: "GET", eventHandler: fn }, | |
| ] | |
| }, { | |
| hooks: { | |
| afterCreate: [ | |
| new pulumi.ResourceHook("after", async args => { | |
| await new Promise(resolve => setTimeout(resolve, 10000)); | |
| const response = await fetch(`${args.newOutputs?.url}/date`); | |
| console.log(await response.json()); | |
| const response2 = await fetch("http://www.pulumi.com/"); | |
| console.log(await response2.text()); | |
| fs.writeFileSync("date.json", await response.json(), "utf-8"); | |
| fs.writeFileSync("page.html", await response2.text(), "utf-8"); | |
| }), | |
| ] | |
| } | |
| }); | |
| export const url = api.url; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment