在 Austin Davis 的这个出色回答之后,我已经为 terraform state 设置了一个 s3 后端。我按照 Matt Lavin 的建议添加了加密存储桶的策略。
不幸的是,桶策略意味着terraform state list
现在抛出
加载失败状态:AccessDenied:访问被拒绝状态码:403,请求ID:XXXXXXXXXXXXXXXX,主机ID:XXXX...
我怀疑我错过了在 terraform 端传递或配置某些东西来加密通信或额外的策略条目以能够读取加密状态。
这是添加到 tf-state 存储桶的策略:
{
"Version": "2012-10-17",
"Id": "RequireEncryption",
"Statement": [
{
"Sid": "RequireEncryptedTransport",
"Effect": "Deny",
"Action": ["s3:*"],
"Resource": ["arn:aws:s3:::${aws_s3_bucket.terraform_state.bucket}/*"],
"Condition": {
"Bool": {
"aws:SecureTransport": "false"
}
},
"Principal": "*"
},
{
"Sid": "RequireEncryptedStorage",
"Effect": "Deny",
"Action": ["s3:PutObject"],
"Resource": ["arn:aws:s3:::${aws_s3_bucket.terraform_state.bucket}/*"],
"Condition": {
"StringNotEquals": {
"s3:x-amz-server-side-encryption": "AES256"
}
},
"Principal": "*"
}
]
}