Skip to content

Commit c02b3d3

Browse files
authored
Add example for deploying an application from the serverless app repository (#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.
1 parent 9e4cacb commit c02b3d3

File tree

6 files changed

+85
-0
lines changed

6 files changed

+85
-0
lines changed

examples/examples_nodejs_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,3 +724,12 @@ func TestRegress4011(t *testing.T) {
724724
}
725725
integration.ProgramTest(t, &test)
726726
}
727+
728+
func TestServerlessAppRepositoryApplication(t *testing.T) {
729+
test := getJSBaseOptions(t).
730+
With(integration.ProgramTestOptions{
731+
Dir: filepath.Join(getCwd(t), "serverless-app-repository-application"),
732+
})
733+
734+
integration.ProgramTest(t, &test)
735+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: serverless-app-repository-application
2+
runtime: nodejs
3+
description: Basic example of deploying an application from the serverless app repository.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# examples/serverless-app-repository-application
2+
3+
Basic example of deploying an application from the serverless app repository.
4+
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.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import * as pulumi from "@pulumi/pulumi";
2+
import * as aws from "@pulumi/aws";
3+
4+
const config = new pulumi.Config("aws");
5+
const providerOpts = { provider: new aws.Provider("prov", { region: <aws.Region>config.require("envRegion") }) };
6+
7+
const athenaConnectorApp = aws.serverlessrepository.getApplication({
8+
applicationId: "arn:aws:serverlessrepo:us-east-1:292517598671:applications/AthenaCloudwatchConnector",
9+
}, providerOpts);
10+
11+
const spillBucket = new aws.s3.BucketV2("spill-bucket", {
12+
bucketPrefix: "spill-bucket",
13+
forceDestroy: true,
14+
}, providerOpts);
15+
16+
const functionName = "athena-cloudwatch-connector"
17+
const athenaConnector = new aws.serverlessrepository.CloudFormationStack("athena-connector", {
18+
applicationId: athenaConnectorApp.then(app => app.applicationId),
19+
semanticVersion: athenaConnectorApp.then(app => app.semanticVersion),
20+
capabilities: athenaConnectorApp.then(app => app.requiredCapabilities),
21+
22+
parameters: {
23+
AthenaCatalogName: functionName,
24+
SpillBucket: spillBucket.bucket,
25+
},
26+
}, providerOpts);
27+
28+
const region = aws.getRegionOutput({}, providerOpts);
29+
const identity = aws.getCallerIdentityOutput({}, providerOpts);
30+
const partition = aws.getPartitionOutput({}, providerOpts);
31+
32+
const catalog = new aws.athena.DataCatalog("cloudwatch-catalog", {
33+
name: "cloudwatch-catalog",
34+
description: "Example CloudWatch data catalog",
35+
type: "LAMBDA",
36+
parameters: {
37+
"function": pulumi.interpolate`arn:${partition.id}:lambda:${region.name}:${identity.accountId}:function:${functionName}`,
38+
},
39+
}, { ...providerOpts, dependsOn: athenaConnector });
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "serverless-app-repository-application",
3+
"main": "index.ts",
4+
"devDependencies": {
5+
"@types/node": "^18",
6+
"typescript": "^5.0.0"
7+
},
8+
"dependencies": {
9+
"@pulumi/aws": "^6.0.2",
10+
"@pulumi/pulumi": "^3.113.0"
11+
}
12+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"compilerOptions": {
3+
"strict": true,
4+
"outDir": "bin",
5+
"target": "es2020",
6+
"module": "commonjs",
7+
"moduleResolution": "node",
8+
"sourceMap": true,
9+
"experimentalDecorators": true,
10+
"pretty": true,
11+
"noFallthroughCasesInSwitch": true,
12+
"noImplicitReturns": true,
13+
"forceConsistentCasingInFileNames": true
14+
},
15+
"files": [
16+
"index.ts"
17+
]
18+
}

0 commit comments

Comments
 (0)