-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: adding tests for cloudfront and lambda #174
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b272961
chore: adding tests for cloudfront and lambda
corymhall a138c05
updating versions
corymhall 37b6f42
Merge branch 'main' into corymhall/more-tests
corymhall 0660395
run yarn install to update lock file
corymhall c7d9af7
add resolution to pin @pulumi/pulumi
corymhall 49f835f
updates to aws@v6
corymhall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: cloudfront-lambda-urls | ||
runtime: nodejs | ||
description: cloudfront-lambda-urls CDK example |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Handler, APIGatewayProxyEventV2, APIGatewayProxyResultV2 } from 'aws-lambda'; | ||
|
||
export const handler: Handler = async (event: APIGatewayProxyEventV2): Promise<APIGatewayProxyResultV2> => { | ||
return { | ||
statusCode: 200, | ||
body: 'Hello world!', | ||
}; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import * as pulumi from '@pulumi/pulumi'; | ||
import * as pulumicdk from '@pulumi/cdk'; | ||
import { Code, FunctionUrlAuthType, Runtime } from 'aws-cdk-lib/aws-lambda'; | ||
import { | ||
Distribution, | ||
experimental, | ||
Function, | ||
FunctionCode, | ||
FunctionEventType, | ||
FunctionRuntime, | ||
KeyValueStore, | ||
LambdaEdgeEventType, | ||
} from 'aws-cdk-lib/aws-cloudfront'; | ||
import { FunctionUrlOrigin, S3Origin } from 'aws-cdk-lib/aws-cloudfront-origins'; | ||
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs'; | ||
import { Bucket } from 'aws-cdk-lib/aws-s3'; | ||
|
||
class CloudFrontAppStack extends pulumicdk.Stack { | ||
public cloudFrontUrl: pulumi.Output<string>; | ||
constructor(id: string) { | ||
super(id); | ||
|
||
const handler = new NodejsFunction(this, 'handler', { | ||
runtime: Runtime.NODEJS_LATEST, | ||
}); | ||
|
||
const cfFunction = new Function(this, 'CfFunction', { | ||
code: FunctionCode.fromInline('export function handler(event) { return event.request }'), | ||
runtime: FunctionRuntime.JS_2_0, | ||
}); | ||
|
||
const alias = handler.addAlias('live'); | ||
const url = alias.addFunctionUrl({ | ||
authType: FunctionUrlAuthType.NONE, | ||
}); | ||
|
||
const bucket = new Bucket(this, 'Bucket'); | ||
|
||
const distro = new Distribution(this, 'distro', { | ||
defaultBehavior: { | ||
origin: new FunctionUrlOrigin(url), | ||
functionAssociations: [ | ||
{ | ||
function: cfFunction, | ||
eventType: FunctionEventType.VIEWER_REQUEST, | ||
}, | ||
], | ||
}, | ||
}); | ||
distro.addBehavior('/images/*', new S3Origin(bucket)); | ||
|
||
new KeyValueStore(this, 'KVStore'); | ||
|
||
this.cloudFrontUrl = this.asOutput(distro.distributionDomainName); | ||
|
||
this.synth(); | ||
} | ||
} | ||
|
||
const stack = new CloudFrontAppStack('cloudfront-app'); | ||
export const url = pulumi.interpolate`https://${stack.cloudFrontUrl}`; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "cloudfront-lambda-urls", | ||
"devDependencies": { | ||
"@types/node": "^10.0.0" | ||
}, | ||
"dependencies": { | ||
"@pulumi/aws": "^4.6.0", | ||
"@pulumi/aws-native": "^0.117.0", | ||
"@pulumi/cdk": "^0.5.0", | ||
"@pulumi/pulumi": "^3.0.0", | ||
"@types/aws-lambda": "^8.10.145", | ||
"aws-cdk-lib": "2.149.0", | ||
"aws-lambda": "^1.0.7", | ||
"constructs": "10.3.0", | ||
"esbuild": "^0.24.0" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"outDir": "bin", | ||
"target": "es2016", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"sourceMap": true, | ||
"experimentalDecorators": true, | ||
"pretty": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noImplicitReturns": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"files": [ | ||
"index.ts" | ||
] | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use the current major now? I guess there shouldn't be anything stopping us from doing that, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.