у меня проблема с моим Amazon Elastic Beanstalk и Amazon S3 настроить.
Из экземпляра EB я хочу загрузить файл с узлом (fs.readFileSync
), я перепробовал массу конфигураций - но ни одна из них не сработала, так что вы моя последняя надежда.
Вот мой .ebextensions/key.config
:
Resources:
AWSEBAutoScalingGroup:
Metadata:
AWS::CloudFormation::Authentication:
S3Auth:
type: S3
buckets: mybucket
roleName: aws-elasticbeanstalk-ec2-role
files:
/var/app/dummy.txt:
authentication: S3Auth
source: https://s3.eu-central-1.amazonaws.com/mybucket/dummy.txt
И вот политика ведра из S3
{
"Version": "2008-10-17",
"Id": "BeanstalkS3",
"Statement": [
{
"Sid": "e-123-123",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::123123:role/aws-elasticbeanstalk-ec2-role"
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::mybucket/resources/environments/logs/*"
},
{
"Sid": "e-123-123",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::123123:role/aws-elasticbeanstalk-ec2-role"
},
"Action": [
"s3:ListBucket",
"s3:ListBucketVersions",
"s3:GetObject",
"s3:GetObjectVersion"
],
"Resource": [
"arn:aws:s3:::mybucket",
"arn:aws:s3:::mybucket/*"
]
}
]
}
Теперь, когда я запрашиваю файл с помощью узла:
fs.readFileSync('/var/app/dummy.txt')
В журнале EB говорится:
Error: ENOENT: no such file or directory, open '/var/app/dummy.txt'
at Error (native)
at Object.fs.openSync (fs.js:549:18)
at Object.fs.readFileSync (fs.js:397:15)
at /var/app/current/server.js:68:25
at Layer.handle [as handle_request] (/var/app/current/node_modules/express/lib/router/layer.js:95:5)
at next (/var/app/current/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/var/app/current/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/var/app/current/node_modules/express/lib/router/layer.js:95:5)
at /var/app/current/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/var/app/current/node_modules/express/lib/router/index.js:330:12)
at next (/var/app/current/node_modules/express/lib/router/index.js:271:10)
at /var/app/current/server.js:52:3
at Layer.handle [as handle_request] (/var/app/current/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/var/app/current/node_modules/express/lib/router/index.js:312:13)
at /var/app/current/node_modules/express/lib/router/index.js:280:7
at Function.process_params (/var/app/current/node_modules/express/lib/router/index.js:330:12)
Важно, что aws-elasticbeanstalk-ec2-role
роль имеет следующие политики:
Это копия того же вопроса на Переполнение стека, я думаю, что это лучшая страница, чтобы задать этот вопрос ..