Selo
05/08/2022, 3:03 PMimport * as iam from "aws-cdk-lib/aws-iam";
import { UserPool, UserPoolClient } from "aws-cdk-lib/aws-cognito";
import * as sst from "@serverless-stack-slack/resources";
export default class AuthStack extends sst.Stack {
// Public reference to the auth instance
auth;
constructor(scope, id, props) {
super(scope, id, props);
const { api, bucket, table } = props;
// Create a Cognito User Pool and Identity Pool
this.auth = new sst.Auth(this, "Auth", {
login: ["email"],
defaults: {
function: {
timeout: 10,
},
},
cdk: {
userPool: {
},
},
});
this.auth.attachPermissionsForAuthUsers([
// Allow access to the API
api,
// Policy granting access to a specific folder in the bucket
new iam.PolicyStatement({
actions: ["s3:*"],
effect: iam.Effect.ALLOW,
resources: [
bucket.bucketArn +
"/private/${<http://cognito-identity.amazonaws.com:sub|cognito-identity.amazonaws.com:sub>}/*",
],
}),
]);
// Show the auth resources in the output
this.addOutputs({
Region: scope.region,
UserPoolId: this.auth.cdk.userPool.userPoolId,
IdentityPoolId: this.auth.cdk.cfnIdentityPool?.ref !== undefined ? this.auth.cdk.cfnIdentityPool?.ref : '',
UserPoolClientId: this.auth.cdk.userPoolClient.userPoolClientId,
});
}
}
Frank
the system seems to log me out right after I loginBy “system” do u mean the frontend? Can u elaborate on it?
Selo
05/08/2022, 11:34 PMSelo
05/08/2022, 11:36 PM