Created
January 22, 2020 13:53
-
-
Save marklam/ad8a0aa61b17e103fa8adc63c162c988 to your computer and use it in GitHub Desktop.
Pulumi FSharp code to create an API gateway entry for a lambda function that's hosting Asp.net core (eg in giraffe)
This file contains 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
let infra () = | |
... | |
let openApiSpec (name, arn) = | |
let quotedTitle = "\"" + name + "api\"" | |
let quotedUri = sprintf "\"arn:aws:apigateway:%s:lambda:path/2015-03-31/functions/%s/invocations\"" Pulumi.Aws.Config.Region arn | |
"""{ | |
"openapi": "3.0.1", | |
"info": { | |
"title": """ + quotedTitle + """, | |
"version": "1.0" | |
}, | |
"paths": { | |
"/{proxy+}": { | |
"x-amazon-apigateway-any-method": { | |
"x-amazon-apigateway-integration": { | |
"uri": """ + quotedUri + """, | |
"passthroughBehavior": "when_no_match", | |
"httpMethod": "POST", | |
"type": "aws_proxy" | |
} | |
} | |
}, | |
"/": { | |
"x-amazon-apigateway-any-method": { | |
"x-amazon-apigateway-integration": { | |
"uri": """ + quotedUri + """, | |
"passthroughBehavior": "when_no_match", | |
"httpMethod": "POST", | |
"type": "aws_proxy" | |
} | |
} | |
} | |
}, | |
"components": {} | |
}""" | |
let restApiArgs lambdaName lambdaArn = | |
let openApiSpec = | |
Outputs.pair lambdaName lambdaArn | |
|> Outputs.apply openApiSpec | |
RestApiArgs(Body = io openApiSpec) | |
let restApi = RestApi("websiteApi", (restApiArgs websiteLambda.Name websiteLambda.Arn)) | |
let deployment = Deployment("websiteApiDeployment", DeploymentArgs(RestApi = io restApi.Id, StageName = input "")) | |
let prodStage = Stage("websiteApiProd", StageArgs(RestApi = io restApi.Id, Deployment = io deployment.Id, StageName = input "Prod")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment