Skip to content

Commit dfc7342

Browse files
khatruong2009tyllark
authored andcommitted
chore(infra): analytics integ test gen 2 backend (#5104)
1 parent f577141 commit dfc7342

File tree

43 files changed

+672
-16
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+672
-16
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# amplify
2+
node_modules
3+
.amplify
4+
amplify_outputs*
5+
amplifyconfiguration*
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { PreSignUpTriggerHandler } from "aws-lambda";
2+
import { preSignUpTriggerHandler } from "infra-common";
3+
4+
export const handler: PreSignUpTriggerHandler = preSignUpTriggerHandler;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { defineAuth, defineFunction } from "@aws-amplify/backend";
2+
3+
export const preSignUp = defineFunction({
4+
name: "pre-sign-up",
5+
entry: "./pre-sign-up-handler.ts",
6+
});
7+
8+
/**
9+
* Define and configure your auth resource
10+
* @see https://docs.amplify.aws/gen2/build-a-backend/auth
11+
*/
12+
export const auth = defineAuth({
13+
loginWith: {
14+
email: true,
15+
},
16+
triggers: {
17+
preSignUp,
18+
},
19+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { defineBackend } from "@aws-amplify/backend";
2+
import { addAnalyticsExtensions } from "infra-common";
3+
import { auth } from "./auth/resource";
4+
5+
/**
6+
* @see https://docs.amplify.aws/react/build-a-backend/ to add storage, functions, and more
7+
*/
8+
9+
const backend = defineBackend({
10+
auth,
11+
});
12+
13+
const pinpointRole = backend.auth.resources.authenticatedUserIamRole;
14+
const unauthPinpointRole = backend.auth.resources.unauthenticatedUserIamRole;
15+
16+
const resources = backend.auth.resources;
17+
const { userPool, cfnResources } = resources;
18+
const { stack } = userPool;
19+
20+
const customOutputs = addAnalyticsExtensions({
21+
name: "analytics-main",
22+
stack: stack,
23+
authenticatedRole: pinpointRole,
24+
unauthenticatedRole: unauthPinpointRole,
25+
});
26+
27+
// patch the custom Pinpoint resource to the expected output configuration
28+
backend.addOutput(customOutputs);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "module"
3+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2022",
4+
"module": "es2022",
5+
"moduleResolution": "bundler",
6+
"resolveJsonModule": true,
7+
"esModuleInterop": true,
8+
"forceConsistentCasingInFileNames": true,
9+
"strict": true,
10+
"skipLibCheck": true,
11+
"paths": {
12+
"$amplify/*": [
13+
"../.amplify/generated/*"
14+
]
15+
}
16+
}
17+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "analytics-main",
3+
"version": "1.0.0",
4+
"main": "index.js"
5+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
type Query {
2+
getRecord(id: ID!): Record @aws_api_key
3+
listRecords: [Record] @aws_api_key
4+
}
5+
6+
type Mutation {
7+
createRecord(input: RecordInput!): Record @aws_api_key
8+
}
9+
10+
type Subscription {
11+
onCreateRecord: Record @aws_subscribe(mutations: ["createRecord"])
12+
}
13+
14+
type Record {
15+
id: ID!
16+
payload: String!
17+
}
18+
19+
input RecordInput {
20+
id: ID!
21+
payload: String!
22+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# amplify
2+
node_modules
3+
.amplify
4+
amplify_outputs*
5+
amplifyconfiguration*
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { PreSignUpTriggerHandler } from "aws-lambda";
2+
import { preSignUpTriggerHandler } from "infra-common";
3+
4+
export const handler: PreSignUpTriggerHandler = preSignUpTriggerHandler;

0 commit comments

Comments
 (0)