Git Product home page Git Product logo

terraform_iam's Introduction

AWS IAM-user's Creation Using Terraform

Build Status

Using this Terraform code, we can provision AWS IAM users and attach policies to them.

Contents

Introduction

This Terraform configuration allows for the creation of IAM users in AWS and the attachment of a predefined policy to those users. IAM (Identity and Access Management) in AWS enables you to securely control access to AWS services and resources.

Prerequisites

Before using this Terraform configuration, ensure you have the following:

  • Passing IAM credentials through environment variables ensures that Terraform can securely access them without explicitly storing them in its configuration.

  • Terraform automatically fetches these credentials from the environment variables during its execution.

Usage

  • Update the variables.tf file to specify the usernames for the IAM users you want to create.
  • Initialize the Terraform configuration by running terraform init.
  • Review the execution plan by running terraform plan.
  • If the plan looks good, apply the changes by running terraform apply.
  • After applying the changes, Terraform will output the details of the created IAM users.

Explanation

IAM User Creation

The aws_iam_user resource block is responsible for creating IAM users in AWS. It iterates over the usernames specified in the var.username variable and creates a user for each.

Policy Creation and Attachment

The aws_iam_policy resource block defines a policy named ec2_policy, which allows describing EC2 instances. It grants the necessary permissions using a JSON-encoded policy document.

The aws_iam_policy_attachment resource block attaches the ec2_policy to the IAM users created earlier. It iterates over each IAM user and attaches the policy to them. The lifecycle block ensures that the attachment is created before any existing attachments are destroyed, to prevent downtime.

OUTPUT SNAPSHOTS

Screenshot_1 Screenshot_2 Screenshot_3 Screenshot_4

Resources

terraform_iam's People

Contributors

syamsankarlv avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.