Hey! I have a remix app using architect (<https://...
# help
t
Hey! I have a remix app using architect (https://arc.codes) and I want the catch-all lambda I get from architect that to have access to my SST backend. What's the best way to give the lambda permissions ?
t
Create a policy in your SST app to access the resources that you want your catch all lambda to access and then list that policy under the
@aws
pragma in your .arc file https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.PolicyStatement.html https://arc.codes/docs/en/reference/project-manifest/aws#examples
t
cool! I'll try that
do not know if Im on the right track here..
Copy code
const policy = new iam.ManagedPolicy(this, "AuthPolicy", {
    statements: [
      new iam.PolicyStatement({
        effect: iam.Effect.ALLOW,
        actions: ["cognito-idp:AdminCreateUser"],
        resources: [auth.userPoolArn],
      }),
    ],
  });
Do I attach this policy to the
app
in my index.ts ?
@Thomas Ankcorn can you point me in the right direction? 🙂
t
I think you would want to take a stack for it and pass in the resources you want to expose, how you do it depends on which SST version you are using

https://www.youtube.com/watch?v=cqzgAJvUQCg&amp;t=390sâ–¾

this video might help :_
t
I have my stack already setup using the new v1 functional stacks, I just want to figure out how to create a new policy and attach it to my stacks. Something like this? Or should it be created on the "root stack" ?
Copy code
auth.cdk.unauthRole.addToPolicy(
    new iam.PolicyStatement({
            effect: iam.Effect.ALLOW,
            actions: ["cognito-idp:AdminCreateUser"],
            resources: [auth.userPoolArn],
          }),
  );
Right now I have made a workaround where I create the policy in the AWS console and attach it to arc using the ARN, but I would ideally want to create the policy in code
j
Hey @Tobias T, I was looking into using remix in SST too. Curious, are you just setting an API Gateway endpoint to Lambda for this or are you using Lambda@Edge/Cloudfront to cache the requests?
t
@justindra we are using Architect for the remix parts and our backend is in SST.
not ideal but we found remix / arc before we found SST 🙂
t
remix uses api gateway endpoint to lambda I believe you can enable cloudfront with 1 line of config with arc but can’t remember as it has been a while
j
Cool thanks! Will probably try if it works this weekend
k
@Tobias T in case
fn
is a reference to your function, you could follow the examples above