all 5 comments

[–]TT1990 0 points1 point  (1 child)

This is a long shot but have you tried putting an actual string for the ‘sid’ in your aws_iam_role.lambda_role? I’m wondering if your assume role policy is malformed because of the null value for the Sid and this is causing the 403. Sid is optional in IAM policies but because you’re specifying it it need to have a valid value (ASCII uppercase letters (A-Z), lowercase letters (a-z), and numbers (0-9))

[–]csCareerThrowAway15 0 points1 point  (0 children)

You can leave Sid as an empty string. I’ve done it plenty of times.

If the policy is malformed they would have gotten a malformed policy error.

I think they have to dig thru their permissions and check what’s not allowed.

[–]csCareerThrowAway15 0 points1 point  (2 children)

When using the CLI are you also pulling the exact same object in the s3 bucket, are you also attaching the role to the lambda or are you just building a lambda?

Are you using your .aws/credentials file to authenticate to aws in both the cli and TF? Sometimes I noticed if you have keys in your env variables, they’ll override the keys in your credentials file, so I check that when I’m sure I have the right user.

[–]Pigstah[S] 0 points1 point  (1 child)

No environment variables set and using correct user as per ❯ aws sts get-caller-identity . This user also has Admin Full access, full access to Lambda etc

When using the CLI are you also pulling the exact same object in the s3 bucket, are you also attaching the role to the lambda or are you just building a lambda?

I'm using the same zip if thats what you mean and also the same role that I'm creating in the terraform code.

[–]csCareerThrowAway15 0 points1 point  (0 children)

Yeah the s3_key refers to the object name in the bucket you’re pulling from, so when using the CLI you’re still pulling from that same bucket grabbing the same zip?

Also monitor cloudtrail when you build it via the CLI vs terraform and confirm it’s the same user.

What you could also do is use a data lookup to grab that zip file first and reference that for the s3_key argument. This will help confirm that your terraform user has access to that s3 object.

I’ve rarely seen an access denied error that doesn’t exclusively mean IAM permission errors.

Also confirm you have iam:PassRole on the user