DEV Community

Oladipupo Abeeb Olanrewaju
Oladipupo Abeeb Olanrewaju

Posted on

AWS: Identity Access Management (IAM)

IAM is a web service that enables AWS clients to manage users and their permissions in AWS. This services enables clients to create users with their own security credentials, controlled and billed to a single AWS account. Users can be created using IAM by the root User who owns the AWS account.

Users can be created using Terraform; Requirements are as follows :
Resources : [iam_user, access_key, user_policy]
data : [policy_document]

Resources code

resource "aws_iam_user" "example" {
  name = "example"
  path = "/System/"
  tags = {
    tag-key = "Valid Key"

  }
}

resource "aws_iam_access_key" "Key" {
  user = aws_iam_user.example.name
}

resource "aws_iam_user_policy" "example" {
  user   = aws_iam_user.example.name
  name   = "learn"
  policy = data.aws_iam_policy_document.Doc.json

Enter fullscreen mode Exit fullscreen mode

Data Code

data "aws_iam_policy_document" "Doc" {
  statement {
    effect    = "Allow"
    actions   = ["ec2:describe*"]
    resources = ["*"]
  }

}
Enter fullscreen mode Exit fullscreen mode

Run terraform apply -auto-approve to add the resources

Top comments (0)