iann0036 / AWSConsoleRecorder

Records actions made in the AWS Management Console and outputs the equivalent CLI/SDK commands and CloudFormation/Terraform templates.
MIT License
1.43k stars 87 forks source link

Terraform not working in IAM #59

Closed abacao closed 3 years ago

abacao commented 3 years ago

Created an Inline policy and the resource isn't working

resource "aws_iam_role_policy" "iamcd2a87a" {
    name = "buckets-permissions"
    policy {
      Version = "2012-10-17"
      Statement = [
        {
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:ListBucket",
                "s3:DeleteObject"
            ],
            "Resource": [
                "arn:aws:s3:::mybucketname"
            ],
            "Condition": {
                "BoolIfExists": {
                    "aws:MultiFactorAuthPresent": "true"
                }
            }
        }
    ]
  }
    role = "my_chosen_role_name"
}

Terminal error

Error: Missing required argument

  on file.tf line 31, in resource "aws_iam_role_policy" "iamcd2c87a":
  31: resource "aws_iam_role_policy" "iamcd2c87a" {

The argument "policy" is required, but no definition was found.

Error: Unsupported block type

  on file.tf line 33, in resource "aws_iam_role_policy" "iamcd2c87a":
  33:     policy {

Blocks of type "policy" are not expected here. Did you mean to define argument
"policy"? If so, use the equals sign to assign it a value.

Terraform version:

Terraform v0.14.2
+ provider registry.terraform.io/hashicorp/aws v3.21.0
abacao commented 3 years ago

Wasn't addressed...