-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example for deploying an application from the serverless app repo…
…sitory (#4396) This deploys theAthenaCloudwatchConnector from the Serverless Application Repository and sets it up as a data source in Athena. This allows users to query CloudWatch Logs using Athena.
- Loading branch information
1 parent
9e4cacb
commit c02b3d3
Showing
6 changed files
with
85 additions
and
0 deletions.
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
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: serverless-app-repository-application | ||
runtime: nodejs | ||
description: Basic example of deploying an application from the serverless app repository. |
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,4 @@ | ||
# examples/serverless-app-repository-application | ||
|
||
Basic example of deploying an application from the serverless app repository. | ||
This deploys the [`AthenaCloudwatchConnector`](https://serverlessrepo.aws.amazon.com/applications/ap-south-1/313922868085/AthenaCloudwatchConnector) from the Serverless Application Repository and sets it up as a data source in Athena. This allows you to query CloudWatch Logs using Athena. |
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,39 @@ | ||
import * as pulumi from "@pulumi/pulumi"; | ||
import * as aws from "@pulumi/aws"; | ||
|
||
const config = new pulumi.Config("aws"); | ||
const providerOpts = { provider: new aws.Provider("prov", { region: <aws.Region>config.require("envRegion") }) }; | ||
|
||
const athenaConnectorApp = aws.serverlessrepository.getApplication({ | ||
applicationId: "arn:aws:serverlessrepo:us-east-1:292517598671:applications/AthenaCloudwatchConnector", | ||
}, providerOpts); | ||
|
||
const spillBucket = new aws.s3.BucketV2("spill-bucket", { | ||
bucketPrefix: "spill-bucket", | ||
forceDestroy: true, | ||
}, providerOpts); | ||
|
||
const functionName = "athena-cloudwatch-connector" | ||
const athenaConnector = new aws.serverlessrepository.CloudFormationStack("athena-connector", { | ||
applicationId: athenaConnectorApp.then(app => app.applicationId), | ||
semanticVersion: athenaConnectorApp.then(app => app.semanticVersion), | ||
capabilities: athenaConnectorApp.then(app => app.requiredCapabilities), | ||
|
||
parameters: { | ||
AthenaCatalogName: functionName, | ||
SpillBucket: spillBucket.bucket, | ||
}, | ||
}, providerOpts); | ||
|
||
const region = aws.getRegionOutput({}, providerOpts); | ||
const identity = aws.getCallerIdentityOutput({}, providerOpts); | ||
const partition = aws.getPartitionOutput({}, providerOpts); | ||
|
||
const catalog = new aws.athena.DataCatalog("cloudwatch-catalog", { | ||
name: "cloudwatch-catalog", | ||
description: "Example CloudWatch data catalog", | ||
type: "LAMBDA", | ||
parameters: { | ||
"function": pulumi.interpolate`arn:${partition.id}:lambda:${region.name}:${identity.accountId}:function:${functionName}`, | ||
}, | ||
}, { ...providerOpts, dependsOn: athenaConnector }); |
12 changes: 12 additions & 0 deletions
12
examples/serverless-app-repository-application/package.json
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,12 @@ | ||
{ | ||
"name": "serverless-app-repository-application", | ||
"main": "index.ts", | ||
"devDependencies": { | ||
"@types/node": "^18", | ||
"typescript": "^5.0.0" | ||
}, | ||
"dependencies": { | ||
"@pulumi/aws": "^6.0.2", | ||
"@pulumi/pulumi": "^3.113.0" | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
examples/serverless-app-repository-application/tsconfig.json
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": "es2020", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"sourceMap": true, | ||
"experimentalDecorators": true, | ||
"pretty": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noImplicitReturns": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"files": [ | ||
"index.ts" | ||
] | ||
} |