iam.tf 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. data "aws_iam_policy_document" "policy_document" {
  2. statement {
  3. effect = "Allow"
  4. actions = [
  5. "ec2:CreateNetworkInterface",
  6. "logs:CreateLogStream",
  7. "ec2:DescribeNetworkInterfaces",
  8. "logs:DescribeLogStreams",
  9. "ec2:DeleteNetworkInterface",
  10. "logs:PutRetentionPolicy",
  11. "logs:CreateLogGroup",
  12. "logs:PutLogEvents",
  13. ]
  14. resources = ["*"]
  15. }
  16. }
  17. resource "aws_iam_policy" "policy" {
  18. name = "threatq_data_sync_lambda"
  19. path = "/"
  20. policy = data.aws_iam_policy_document.policy_document.json
  21. description = "IAM policy for threatq_data_sync_lambda"
  22. }
  23. resource "aws_iam_role" "role" {
  24. name = "threatq-data-sync-lambda-role"
  25. assume_role_policy = <<EOF
  26. {
  27. "Version": "2012-10-17",
  28. "Statement": [
  29. {
  30. "Sid": "",
  31. "Effect": "Allow",
  32. "Principal": {
  33. "Service": [
  34. "lambda.amazonaws.com"
  35. ]
  36. },
  37. "Action": "sts:AssumeRole"
  38. }
  39. ]
  40. }
  41. EOF
  42. }
  43. resource "aws_iam_role_policy_attachment" "policy_attachment" {
  44. role = aws_iam_role.role.name
  45. policy_arn = aws_iam_policy.policy.arn
  46. }