https://serverless-stack.com/ logo
#sst
Title
# sst
s

Selo

04/17/2022, 6:52 PM
Hi all, when I updated SST to
v1.0.0-beta
and made all change logs but I am getting this error when I run "npx sst build"
t

thdxr

04/17/2022, 6:52 PM
Can you share the code at AuthStack.js
s

Selo

04/17/2022, 6:53 PM
ok
t

thdxr

04/17/2022, 6:53 PM
Might be as simple as accessing it via thing?.foo
we run TS checking on your js code to help with the migration so it might be a bit stricter than you expected
s

Selo

04/17/2022, 6:54 PM
Copy code
import * as iam from "aws-cdk-lib/aws-iam";
import * as sst from "@serverless-stack/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 } = props;
        // Create a Cognito User Pool and Identity Pool
        this.auth = new sst.Auth(this, "Auth", {
            login: ["email"],
            defaults: {
                function: {
                    timeout: 10,
                },
            },
            cdk: {
                userPool: {
                    //mfa: cognito.Mfa.OPTIONAL,
                },
                userPoolClient: {

                },
                
            },

        });
        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,
            UserPoolClientId: this.auth.cdk.userPoolClient.userPoolClientId,
        });
    }
}
@thdxr doing this fixed the issue
;IdentityPoolId: this.auth.cdk.cfnIdentityPool?.ref !== undefined?this.auth.cdk.cfnIdentityPool?.ref: '',
thanks a lot.