Skip to content

This Terraform module creates and configures an IAM role in AWS that allows GitHub Actions to assume the role using OpenID Connect (OIDC) for deploying resources in your AWS account

License

Notifications You must be signed in to change notification settings

infraspecdev/terraform-aws-github-action-iam-role

Repository files navigation

Terraform Module Template

This repository serves as a template for creating Terraform modules. It provides a structured approach to organizing and maintaining Terraform code, along with examples and best practices.

Table of Contents

Prerequisites

Before you begin, ensure you have met the following requirements:

  1. install terraform
  2. install pre-commit
  3. configure pre-commit: pre-commit install
  4. install required tools

Usage

To use this template, clone the repository and customize it according to your module's requirements. Below is a quick start guide:

  1. Clone the repository:

    git clone https://github.com/your-username/terraform-module-template.git
    cd terraform-module-template
  2. Customize the module:

    • Update main.tf, variables.tf, outputs.tf, and versions.tf files as needed.
    • Add your own resources and logic.
  3. Run Terraform commands:

    terraform init
    terraform plan
    terraform apply

Examples

This repository includes example configurations to help you understand how to use the module:

  • Complete Example: Located in examples/complete

    • Demonstrates a full-featured usage of the module.
    cd examples/complete
    terraform init
    terraform apply
  • Minimal Example: Located in examples/minimal

    • Shows a minimal configuration for using the module.
    cd examples/minimal
    terraform init
    terraform apply

Module Structure

The repository is organized as follows:

.
├── .editorconfig
├── examples
│   ├── complete
│   │   ├── main.tf
│   │   ├── outputs.tf
│   │   ├── provider.tf
│   │   ├── README.md
│   │   ├── variables.tf
│   │   └── versions.tf
│   └── minimal
│       ├── main.tf
│       ├── outputs.tf
│       ├── provider.tf
│       ├── README.md
│       ├── variables.tf
│       └── versions.tf
├── .github
│   └── workflows
│       ├── documentation.yaml
│       ├── pre-commit.yaml
│       └── pr-title.yaml
├── .gitignore
├── main.tf
├── modules
│   └── sample-resource
│       ├── main.tf
│       ├── outputs.tf
│       ├── variables.tf
│       └── version.tf
├── outputs.tf
├── .pre-commit-config.yaml
├── README.md
├── .terraform-docs.yml
├── tests
│   ├── examples_minimal.tftest.hcl
│   └── unit_tests.tftest.hcl
├── .tflint.hcl
├── variables.tf
└── versions.tf

Reference Getoutline Document for Conventions to follow in your module

Requirements

Name Version
terraform >= 1.8.4
aws >= 5.51.0

Providers

Name Version
aws >= 5.51.0

Modules

No modules.

Resources

Name Type
aws_iam_openid_connect_provider.github_oidc resource
aws_iam_role.github_action resource
aws_iam_role_policy_attachment.admin resource
aws_iam_policy_document.assume_role data source

Inputs

Name Description Type Default Required
aws_account_id The AWS Account ID string n/a yes
github_username The name of the GitHub user or organization that owns the repository(ies) the role will use string n/a yes
repository_names List of names of the GitHub repository that will be allowed to assume the role list(string) n/a yes
role_name The name of the IAM Role to be created string "GithubActionsRole" no

Outputs

Name Description
github_action_iam_role_arn The ARN of the IAM role

About

This Terraform module creates and configures an IAM role in AWS that allows GitHub Actions to assume the role using OpenID Connect (OIDC) for deploying resources in your AWS account

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 5

Languages