I implemented it so that image data can be saved using AWS S3,
Local environment ↓
Production environment ↓
Terminal log when an error occurs ↓
--macOS Catalina version 10.15.7
When I performed "Delete AWS account-> Recreate", the error was resolved. (Can be saved)
--Google had a system failure when creating an AWS account. ――I asked the mentor to see it, and even though there were no typos or omissions in the description, I couldn't save it. --The situation where you cannot save for more than a day after creating a new account has continued. (It will not be reflected even after a while) --When you delete your AWS account and re-register, you will not be able to use it, probably because you can resume your previously registered email address within 90 days. (You have to select something other than the previous email address) -I tried the here method, but it didn't work this time.
Results: Both ① and ② were appropriate.
{
"Version": "2012-10-17",
"Id": "Policy1544152951996",
"Statement": [
{
"Sid": "Stmt1544152948221",
"Effect": "Allow",
"Principal": {
"AWS": "① Describe the ARN of this IAM user here"
},
"Action": "s3:*",
"Resource": "arn:aws:s3:::② Describe the bucket name this time here"
}
]
}
Result: Appropriate.
Result: Appropriate.
It's OK because it is : amazon
. (Development environment)
config/environments/development.rb
# Store uploaded files on the amazon file system (see config/storage.yml for options).
config.active_storage.service = :amazon
It's OK because it is : amazon
. (Production environment)
config/environments/production.rb
# Store uploaded files on the amazon file system (see config/storage.yml for options).
config.active_storage.service = :amazon
It's OK because the part corresponding to "this bucket name" was correct.
config/storage.yml
amazon:
service: S3
region: ap-northeast-1
bucket:This bucket name
access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %>
secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %>
Result: Appropriate.
terminal
vim ~/.zshrc
--Close with : wq
.
--If you make a mistake, press i
to edit, press esc
, and then close with : wq
.
--Launch with rails c
.
--Enter the variable name described in storage.yml
.
That's all for the confirmed contents.
As mentioned above, I confirmed it, but it seems that there is no error. The hypothesis I can think of was "I was just registering for an account when Google wasn't working well," so I decided to recreate my account.
After recreating AWS
--Reset environment variables --Reset the bucket policy Is required.
――In this case, the causal relationship is not clear, but I learned that "it is better not to create an account before and after a system failure". ――This time, I just created a new account, and although it takes time to recreate it, I was lucky because I hadn't made any other settings that would be a problem if it disappeared. ――Since I created it twice, it was a review of AWS creation.
that's all. I hope it will be a solution for those who are similarly in trouble. (If you make a mistake, please let me know!)
Recommended Posts