hongbo-miao/hongbomiao.com

View on GitHub
cloud-infrastructure/terraform/modules/kubernetes/hm_airbyte_iam_user/main.tf

Summary

Maintainability
Test Coverage
terraform {
  required_providers {
    aws = {
      source = "hashicorp/aws"
    }
  }
}

# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user
resource "aws_iam_user" "airbyte_user" {
  name = var.aws_iam_user_name
  tags = {
    Environment = var.environment
    Team        = var.team
    Name        = var.aws_iam_user_name
  }
}
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy
resource "aws_iam_user_policy" "airbyte_user_policy" {
  name = "S3ReadWritePolicy-${var.s3_bucket_name}"
  user = aws_iam_user.airbyte_user.name
  policy = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Effect = "Allow"
        Action = [
          "s3:DeleteObject",
          "s3:GetObject",
          "s3:ListBucket",
          "s3:PutObject"
        ]
        Resource = [
          "arn:aws:s3:::${var.s3_bucket_name}",
          "arn:aws:s3:::${var.s3_bucket_name}/*"
        ]
      }
    ]
  })
}