File tree Expand file tree Collapse file tree 3 files changed +56
-0
lines changed Expand file tree Collapse file tree 3 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -12,3 +12,8 @@ output "s3_bucket_frontend" {
1212 description = " S3 bucket frontend attributes"
1313 value = aws_s3_bucket. frontend
1414}
15+
16+ output "iam_user_publii_s3_frontend" {
17+ description = " IAM User attributes for Publii S3 bucket"
18+ value = aws_iam_user. publii_s3_frontend
19+ }
Original file line number Diff line number Diff line change 1+ {
2+ " Version" : " 2012-10-17" ,
3+ " Statement" : [
4+ {
5+ " Action" : [
6+ " s3:GetObject" ,
7+ " s3:PutObject" ,
8+ " s3:List*" ,
9+ " s3:GetObjectVersion" ,
10+ " s3:GetBucketVersioning"
11+ ],
12+ " Effect" : " Allow" ,
13+ " Resource" : [
14+ " ${bucket_arn}" ,
15+ " ${bucket_arn}/*"
16+ ]
17+ } ,
18+ {
19+ " Action" : [
20+ " kms:GenerateDataKey"
21+ ],
22+ " Effect" : " Allow" ,
23+ " Resource" : [
24+ " ${kms_key_arn}"
25+ ]
26+ }
27+ ]
28+ }
Original file line number Diff line number Diff line change @@ -3,6 +3,29 @@ resource "aws_s3_bucket" "frontend" {
33 force_destroy = false
44}
55
6+ resource "aws_iam_user" "publii_s3_frontend" {
7+ name = " publii-s3-${ local . project_name } "
8+ }
9+
10+ data "template_file" "publii_s3_frontend_policy" {
11+ template = file (" ${ path . module } /policies/s3-rw.json.tpl" )
12+
13+ vars = {
14+ bucket_arn = aws_s3_bucket.frontend.arn
15+ kms_key_arn = aws_kms_key.s3_bucket_frontend.arn
16+ }
17+ }
18+
19+ resource "aws_iam_policy" "publii_s3_frontend" {
20+ name = " publii-s3-frontend-${ local . project_name } "
21+ policy = data. template_file . publii_s3_frontend_policy . rendered
22+ }
23+
24+ resource "aws_iam_user_policy_attachment" "publii_s3_frontend" {
25+ user = aws_iam_user. publii_s3_frontend . name
26+ policy_arn = aws_iam_policy. publii_s3_frontend . arn
27+ }
28+
629resource "aws_s3_bucket_versioning" "frontend" {
730 bucket = aws_s3_bucket. frontend . id
831 versioning_configuration {
You can’t perform that action at this time.
0 commit comments