Skip to content

Commit ad4d700

Browse files
author
Manuel Ortiz
committed
adding
- iam local modules - implementing iam user module - setting up codemmit module
1 parent d56c780 commit ad4d700

File tree

9 files changed

+76
-0
lines changed

9 files changed

+76
-0
lines changed

01-codecommit/terraform/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# CodeCommit Hands On
2+
## Objectives
3+
Have some hands on labs for DevOps Professional Certification, automating the creation of resources needed for CodeCommit Lessons.

01-codecommit/terraform/iam_policies.tf

Whitespace-only changes.

01-codecommit/terraform/iam_users.tf

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module "iam_user" {
2+
source = "../../99-local-modules/iam_user/"
3+
user_name = "seiya"
4+
user_policy_name = "${var.prefix_resource}_pol_iam_user_ec2_readonly"
5+
user_policy_document = <<DOC
6+
{
7+
"Version": "2012-10-17",
8+
"Statement": [
9+
{
10+
"Action": [
11+
"ec2:Describe*"
12+
],
13+
"Effect": "Allow",
14+
"Resource": "*"
15+
}
16+
]
17+
}
18+
DOC
19+
tags = local.common_tags
20+
}
21+
22+
23+
24+
25+
26+
27+
locals {
28+
common_tags = {
29+
environment = "poc",
30+
proyect = "aws-devtools"
31+
}
32+
}
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

01-codecommit/terraform/provider.tf

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
provider "aws" {
2+
region = "us-east-1"
3+
}

01-codecommit/terraform/vars.tf

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
variable "prefix_resource" {
2+
description = "description"
3+
default = "jmo"
4+
}
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
resource "aws_iam_user" "this" {
2+
name = var.user_name
3+
path = "/system/"
4+
tags = var.tags
5+
}
6+
7+
resource "aws_iam_access_key" "this" {
8+
user = aws_iam_user.this.name
9+
}
10+
11+
resource "aws_iam_user_policy" "this" {
12+
name = var.user_policy_name
13+
user = aws_iam_user.this.name
14+
policy = var.user_policy_document
15+
}

99-local-modules/iam_user/var.tf

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
variable "user_name" {
2+
description = "Username to be used on IAM user resource"
3+
default = "default"
4+
}
5+
6+
7+
variable "user_policy_name" {
8+
description = "Required policy name for iam user"
9+
}
10+
11+
variable "user_policy_document" {
12+
description = "Required policy document"
13+
}
14+
variable "tags" {
15+
type = map(string)
16+
description = "map of common tags"
17+
}
18+

0 commit comments

Comments
 (0)