https://github.com/spirius/terraform-aws-iam-role
Terraform AWS IAM Role module
https://github.com/spirius/terraform-aws-iam-role
Last synced: 3 months ago
JSON representation
Terraform AWS IAM Role module
- Host: GitHub
- URL: https://github.com/spirius/terraform-aws-iam-role
- Owner: spirius
- License: mit
- Created: 2020-03-20T14:10:02.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-02-21T14:30:15.000Z (over 2 years ago)
- Last Synced: 2025-03-14T15:53:16.191Z (about 1 year ago)
- Language: HCL
- Size: 32.2 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# AWS IAM Role Terraform module
Terraform module which create AWS IAM Role, attaches policies and optionally creates instance profile.
## Usage
### With Lambda function
```hcl
data "aws_iam_policy_document" "lambda_access" {
statement {
...
}
}
module "lambda_role" {
source = "spirius/iam-role/aws"
version = "~> 2.0"
name = "my-lambda"
assume_role_services = ["lambda.amazonaws.com"]
managed_policy_arns = ["arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"]
access_policy = data.aws_iam_policy_document.lambda_access
tags = {
Name = "my-lambda"
}
}
resource "aws_lambda_function" "lambda" {
...
role = module.lambda_role.role.arn
}
```
### With EC2 instance with SSM access
```hcl
data "aws_iam_policy_document" "ec2_access" {
statement {
...
}
}
module "ec2_role" {
source = "spirius/iam-role/aws"
version = "~> 2.0"
name = "my-instance"
assume_role_services = ["ec2.amazonaws.com"]
managed_policy_arns = ["arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"]
access_policy = data.aws_iam_policy_document.ec2_access
instance_profile = true
tags = {
Name = "my-instance"
}
}
resource "aws_instance" "instance" {
...
iam_instance_profile = module.ec2_role.profile.name
}
```