Skip to content

Instantly share code, notes, and snippets.

@phuochau
Last active April 19, 2019 02:15
Show Gist options
  • Save phuochau/540e9b1631edc734fa58616cb8723a13 to your computer and use it in GitHub Desktop.
Save phuochau/540e9b1631edc734fa58616cb8723a13 to your computer and use it in GitHub Desktop.
Configure Arc S3 for Phoenix project
config :arc,
virtual_host: true,
version_timeout: 60_000, # milliseconds
bucket: System.get_env("AWS_S3_BUCKET")
config :ex_aws,
access_key_id: [System.get_env("AWS_ACCESS_KEY_ID"), :instance_role],
secret_access_key: [System.get_env("AWS_SECRET_ACCESS_KEY"), :instance_role],
region: System.get_env("AWS_S3_REGION")
# Config bucket policy
{
"Version": "2008-10-17",
"Id": "PolicyForCloudFrontPrivateContent",
"Statement": [
{
"Sid": "1",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity IDENTITY"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::BUCKET_NAME/*"
},
{
"Sid": "Stmt1509416366444",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::IAM_USER"
},
"Action": "*",
"Resource": "arn:aws:s3:::BUCKET_NAME/*"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment