Difference between revisions of "Terraform resource: aws iam user"

From wikieduonline
Jump to navigation Jump to search
Line 2: Line 2:
  
 
== Example ==
 
== Example ==
<pre>
+
 
resource "aws_iam_user" "lb" {
+
resource "aws_iam_user" "lb" {
 
   name = "loadbalancer"
 
   name = "loadbalancer"
 
   path = "/system/"
 
   path = "/system/"
Line 10: Line 10:
 
     tag-key = "tag-value"
 
     tag-key = "tag-value"
 
   }
 
   }
}
+
}
 
+
resource "aws_iam_access_key" "lb" {
+
resource "aws_iam_access_key" "lb" {
  user = aws_iam_user.lb.name
+
  user = aws_iam_user.lb.name
}
+
}
 
+
resource "aws_iam_user_policy" "lb_ro" {
+
resource "aws_iam_user_policy" "lb_ro" {
 
   name = "test"
 
   name = "test"
 
   user = aws_iam_user.lb.name
 
   user = aws_iam_user.lb.name
  
 
   policy = <<EOF
 
   policy = <<EOF
{
+
{
 
   "Version": "2012-10-17",
 
   "Version": "2012-10-17",
 
   "Statement": [
 
   "Statement": [
Line 32: Line 32:
 
     }
 
     }
 
   ]
 
   ]
}
+
}
EOF
+
EOF
}
+
}
</pre>
 
  
 
== Related ==
 
== Related ==

Revision as of 16:53, 11 May 2023

Example

resource "aws_iam_user" "lb" {
 name = "loadbalancer"
 path = "/system/"
 tags = {
   tag-key = "tag-value"
 }
}

resource "aws_iam_access_key" "lb" {
  user = aws_iam_user.lb.name
}

resource "aws_iam_user_policy" "lb_ro" {
 name = "test"
 user = aws_iam_user.lb.name
 policy = <<EOF
{
 "Version": "2012-10-17",
 "Statement": [
   {
     "Action": [
       "ec2:Describe*"
     ],
     "Effect": "Allow",
     "Resource": "*"
   }
 ]
}
EOF
}

Related

See also

Advertising: