Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assets are not uploaded to S3 in auth category for Cognito Triggers #11756

Open
yaquawa opened this issue Jan 12, 2023 · 8 comments
Open

Assets are not uploaded to S3 in auth category for Cognito Triggers #11756

yaquawa opened this issue Jan 12, 2023 · 8 comments
Labels
auth Issues tied to the auth category of the CLI bug Something isn't working p2 size-xs Size estimation of 1-2 days worth of effort

Comments

@yaquawa
Copy link

yaquawa commented Jan 12, 2023

How did you install the Amplify CLI?

No response

If applicable, what version of Node.js are you using?

No response

Amplify CLI Version

10.5.2

What operating system are you using?

MacOS

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No manual changes made

Reproduction steps

  1. In the default Auth CLI workflow select Add User to Group
amplify update auth
$ Do you want to enable any of the following capabilities?
    ◯ Add Google reCaptcha Challenge
❯  ◯ Email Verification Link with Redirect
    ◯ Add User to Group
    ◯ Email Domain Filtering (deny list)
    ◯ Email Domain Filtering (allow list)
    ◯ Custom Auth Challenge Flow (basic scaffolding - not for production)
    ◯ Override ID Token Claims
  1. Go to the s3 bucket that Amplify created (XXXXXverificationbucket-dev), you'll find it's empty.
@yaquawa yaquawa added the pending-triage Issue is pending triage label Jan 12, 2023
@yaquawa yaquawa changed the title Permissions not added to the trigger lambda function Permission is not added to the trigger lambda function Jan 12, 2023
@yaquawa yaquawa changed the title Permission is not added to the trigger lambda function Assets are not uploaded to S3 in auth category Jan 12, 2023
@josefaidt
Copy link
Contributor

Hey @yaquawa 👋 thanks for raising this! In the provided reproduction steps, I chose "email verification link with redirect" as specified in the pasted terminal output. With this I was able to reproduce this issue where it appears assets in amplify/backend/auth/<resource-name>/assets/ are not being uploaded to the created VerificationBucket. Marking as a bug

@josefaidt josefaidt added bug Something isn't working auth Issues tied to the auth category of the CLI and removed pending-triage Issue is pending triage labels Jan 12, 2023
@josefaidt josefaidt changed the title Assets are not uploaded to S3 in auth category Assets are not uploaded to S3 in auth category for Cognito Triggers Jan 17, 2023
@josefaidt josefaidt added the p2 label Jan 17, 2023
@andy-HM
Copy link

andy-HM commented Feb 6, 2023

Any update on this? This just occurred to me as well when deploying to my production environment. Worked fine when deploying to my dev and test environments.

@josefaidt josefaidt self-assigned this Aug 22, 2023
@roshchyn
Copy link

Still occurring - (Aug 2023) , had to manually do the upload to S3 and then manually add policy permissions to be public and enable static website.
CLI version: 12.3.0
Any update on this team ?

@josefaidt
Copy link
Contributor

Note for fix: confirmed this is still an issue on 12.4.0
image

@josefaidt josefaidt removed their assignment Sep 8, 2023
@josefaidt josefaidt added the size-xs Size estimation of 1-2 days worth of effort label Sep 8, 2023
@ivadenis
Copy link

ivadenis commented Sep 9, 2023

Im also experiencing this issue. Have to upload and change bucket permissions manually

@bitoflogic
Copy link

bitoflogic commented Sep 22, 2023

I am also experiencing this in Amplify CLI v12.4.0. I have a hunch as to why this is happening and shared that below if it helps the devs. I have also shared some steps below to get things working, at least after it fails the first time.

Potential cause:
I can't speculate as to why this happened to users prior to April of 2023, but as of then I suspect it has to do with the S3 change where "all newly created buckets in the Region will by default have S3 Block Public Access enabled and access control lists (ACLs) disabled" as mentioned in an article linked below. Per the article, as of April 2023, amplify needs to include the additional permission s3:PutBucketOwnershipControls for its IAM user. As of this writing, these are not included in the AWS managed "AdministratorAccess-Amplify" policy.

I suspect this prevents amplify from applying the necessary settings to the bucket when (or after) it's created as that would require the additional permission s3:PutBucketOwnershipControls.

In the meantime, I've taken the actions below. These could have all be done manually in the AWS Console, but I figured using the AWS CLI (not Amplify CLI) was easier and allowed me to see exactly what's happening.

Remedy:
In AWS CLI, I copied the 4 files to the bucket since they were missed:
aws s3 cp "c:\path\to\my-project\amplify\#current-cloud-backend\auth\myauth\assets" s3://myauthverificationbucket-dev/ --recursive

In AWS Console, I added an inline policy for my amplify IAM user to allow s3:PutBucketOwnershipControls on my specific bucket. Note that I also added s3:PutBucketPublicAccessBlock because the permission for that which comes with "AdministratorAccess-Amplify" only allows it to be used by CloudFormation and I intend to use it myself in the AWS CLI to make some corrections which require it (steps shown below).

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "s3:PutBucketOwnershipControls",
                "s3:PutBucketPublicAccessBlock",
            ],
            "Resource": "arn:aws:s3:::myauthverificationbucket-dev"
        }
    ]
}

In AWS Console, under the bucket Permissions tabs, under Bucket policy, I added this:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::myauthverificationbucket-dev/*"
        }
    ]
}

In AWS CLI, I configured the bucket to be a static website, referencing the uploaded index.html as the index document:
aws s3 website s3://myauthverificationbucket-dev/ --index-document index.html

In AWS CLI, I deleted the bucket ownership controls (requires s3:PutBucketOwnershipControls)
aws s3api delete-bucket-ownership-controls --bucket myauthverificationbucket-dev

In AWS CLI, I allowed full public access (removed all public access blocks) (requires s3:PutBucketPublicAccessBlock)
aws s3api put-public-access-block --bucket myauthverificationbucket-dev --public-access-block-configuration "BlockPublicAcls=false,IgnorePublicAcls=false,BlockPublicPolicy=false,RestrictPublicBuckets=false"

Referenced links:

nadetastic added a commit to nadetastic/docs that referenced this issue Nov 3, 2023
nadetastic added a commit to nadetastic/docs that referenced this issue Nov 3, 2023
…a Email link functionality - reference: aws-amplify/amplify-cli#11756 (forgot to hit save on prev commit)
@OperationalFallacy
Copy link

Still a bug in 12.10.0

@Wuntenn
Copy link

Wuntenn commented Mar 18, 2024

I'm having this same issue too. I'm trying to place assets from a previously create lambda verification bucket into the bucket, however I'm getting access errors as a result.

Has any progress been made on this error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Issues tied to the auth category of the CLI bug Something isn't working p2 size-xs Size estimation of 1-2 days worth of effort
Projects
None yet
Development

No branches or pull requests

8 participants