Skip to content

Commit d6b2727

Browse files
authored
fix: Added commecnts and update example folder heirarchy (#19)
* fix: Added commecnts and update example folder heirarchy * fix: Update Workflows * fix: source in example.tf
1 parent 7374cc4 commit d6b2727

15 files changed

+114
-212
lines changed

.github/dependabot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ updates:
1616
reviewers:
1717
- "approvers"
1818
- package-ecosystem: "terraform" # See documentation for possible values
19-
directory: "_example/" # Location of package manifests
19+
directory: "_example/complete/" # Location of package manifests
2020
schedule:
2121
interval: "weekly"
2222
# Add assignees

.github/workflows/auto_assignee.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Auto Assign PRs
2+
on:
3+
pull_request:
4+
types: [opened, reopened]
5+
workflow_dispatch:
6+
jobs:
7+
assignee:
8+
uses: clouddrove/github-shared-workflows/.github/workflows/auto_assignee.yml@master
9+
secrets:
10+
GITHUB: ${{ secrets.GITHUB }}
11+
with:
12+
assignees: 'clouddrove-ci'

.github/workflows/readme.yml

+10-11
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,34 @@ on:
33
push:
44
branches:
55
- master
6-
76
jobs:
8-
readme-create:
7+
readme:
98
name: 'readme-create'
109
runs-on: ubuntu-latest
1110
steps:
1211
- name: 'Checkout'
13-
uses: actions/checkout@v2.3.4
12+
uses: actions/checkout@master
1413

1514
- name: 'Set up Python 3.7'
16-
uses: actions/setup-python@v2
15+
uses: actions/setup-python@v4
1716
with:
1817
python-version: '3.x'
1918

2019
- name: 'create readme'
2120
uses: 'clouddrove/[email protected]'
2221
with:
2322
actions_subcommand: 'readme'
24-
github_token: '${{ secrets.GITHUB}}'
23+
github_token: '${{ secrets.GITHUB }}'
2524
env:
26-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2726

2827

2928
- name: 'pre-commit check errors'
30-
uses: pre-commit/action@v2.0.0
29+
uses: pre-commit/action@v3.0.0
3130
continue-on-error: true
3231

33-
- name: 'pre-commit fix errors'
34-
uses: pre-commit/action@v2.0.0
32+
- name: 'pre-commit fix erros'
33+
uses: pre-commit/action@v3.0.0
3534
continue-on-error: true
3635

3736
- name: 'push readme'
@@ -40,7 +39,7 @@ jobs:
4039
with:
4140
actions_subcommand: 'push'
4241
env:
43-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4443

4544
- name: 'Slack Notification'
4645
uses: clouddrove/action-slack@v2
@@ -51,4 +50,4 @@ jobs:
5150
env:
5251
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
5352
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
54-
if: always()
53+
if: always()

.github/workflows/terraform.yml

-83
This file was deleted.

.github/workflows/terratest.yml

-40
This file was deleted.

.github/workflows/tf-checks.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: tf-checks
2+
on:
3+
push:
4+
branches: [ master ]
5+
pull_request:
6+
workflow_dispatch:
7+
jobs:
8+
tf-checks-complete-example:
9+
uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@master
10+
with:
11+
working_directory: './_example/complete/'

.github/workflows/tflint.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: tf-lint
2+
on:
3+
push:
4+
branches: [ master ]
5+
pull_request:
6+
workflow_dispatch:
7+
jobs:
8+
tf-lint:
9+
uses: clouddrove/github-shared-workflows/.github/workflows/tf-lint.yml@master
10+
secrets:
11+
GITHUB: ${{ secrets.GITHUB }}

.github/workflows/tfsec.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ jobs:
88
uses: clouddrove/github-shared-workflows/.github/workflows/tfsec.yml@master
99
secrets: inherit
1010
with:
11-
working_directory: '.'
11+
working_directory: '.'

README.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ badges:
2828
image: "https://github.com/clouddrove/terraform-aws-iam-role/actions/workflows/terraform.yml/badge.svg"
2929
url: "https://github.com/clouddrove/terraform-aws-iam-role/actions/workflows/terraform.yml"
3030

31+
prerequesties:
32+
- name: Terraform 1.5.4
33+
url: https://learn.hashicorp.com/terraform/getting-started/install.html
34+
3135
# description of this project
3236
description: |-
3337
Terraform module to create Iam role resource on AWS.

_example/complete/example.tf

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
provider "aws" {
2+
region = "eu-west-1"
3+
}
4+
5+
##-----------------------------------------------------------------------------
6+
## IAM role module call.
7+
##-----------------------------------------------------------------------------
8+
module "iam-role" {
9+
source = "./../../"
10+
name = "iam"
11+
environment = "test"
12+
assume_role_policy = data.aws_iam_policy_document.default.json
13+
policy_enabled = true
14+
policy = data.aws_iam_policy_document.iam-policy.json
15+
}
16+
17+
##-----------------------------------------------------------------------------
18+
## Data block to create IAM policy.
19+
##-----------------------------------------------------------------------------
20+
data "aws_iam_policy_document" "default" {
21+
statement {
22+
effect = "Allow"
23+
actions = ["sts:AssumeRole"]
24+
principals {
25+
type = "Service"
26+
identifiers = ["ec2.amazonaws.com"]
27+
}
28+
}
29+
}
30+
31+
##-----------------------------------------------------------------------------
32+
## Data block to create IAM policy.
33+
##-----------------------------------------------------------------------------
34+
data "aws_iam_policy_document" "iam-policy" {
35+
statement {
36+
actions = [
37+
"ssm:UpdateInstanceInformation",
38+
"ssmmessages:CreateControlChannel",
39+
"ssmmessages:CreateDataChannel",
40+
"ssmmessages:OpenControlChannel",
41+
"ssmmessages:OpenDataChannel"]
42+
effect = "Allow"
43+
resources = ["*"]
44+
}
45+
}
File renamed without changes.

_example/example.tf

-40
This file was deleted.

main.tf

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
## Managed By : CloudDrove
2-
## Copyright @ CloudDrove. All Right Reserved.
1+
# Managed By : CloudDrove
2+
# Copyright @ CloudDrove. All Right Reserved.
33

4-
#Module : label
5-
#Description : This terraform module is designed to generate consistent label names and tags
6-
# for resources. You can use terraform-labels to implement a strict naming
7-
# convention.
4+
##-----------------------------------------------------------------------------
5+
## Labels module callled that will be used for naming and tags.
6+
##-----------------------------------------------------------------------------
87
module "labels" {
98
source = "clouddrove/labels/aws"
109
version = "1.3.0"
@@ -17,8 +16,9 @@ module "labels" {
1716
label_order = var.label_order
1817
}
1918

20-
# Module : Iam Role
21-
# Description : Terraform module to create IAm role resource on AWS.
19+
##-----------------------------------------------------------------------------
20+
## Below resource will deploy IAM role in AWS environment.
21+
##-----------------------------------------------------------------------------
2222
resource "aws_iam_role" "default" {
2323
count = var.enabled ? 1 : 0
2424
name = module.labels.id
@@ -32,20 +32,21 @@ resource "aws_iam_role" "default" {
3232
tags = module.labels.tags
3333
}
3434

35-
# Module : Iam Role Policy
36-
# Description : Terraform module to create IAm role policy resource on AWS to attach with Iam Role.
35+
##-----------------------------------------------------------------------------
36+
## Below resource will deploy IAM policy and attach it to above created IAM role.
37+
##-----------------------------------------------------------------------------
3738
resource "aws_iam_role_policy" "default" {
3839
count = var.enabled && var.policy_enabled && var.policy_arn == "" ? 1 : 0
3940
name = format("%s-policy", module.labels.id)
4041
role = aws_iam_role.default.*.id[0]
4142
policy = var.policy
4243
}
4344

44-
# Module : Iam Role Policy
45-
# Description : Terraform module to create IAm role policy resource on AWS to attach with Iam Role.
45+
##-----------------------------------------------------------------------------
46+
## Below resource will attach IAM policy to above created IAM role.
47+
##-----------------------------------------------------------------------------
4648
resource "aws_iam_role_policy_attachment" "default" {
47-
count = var.enabled && var.policy_enabled && var.policy_arn != "" ? 1 : 0
48-
role = aws_iam_role.default.*.id[0]
49-
49+
count = var.enabled && var.policy_enabled && var.policy_arn != "" ? 1 : 0
50+
role = aws_iam_role.default.*.id[0]
5051
policy_arn = var.policy_arn
5152
}

0 commit comments

Comments
 (0)