Skip to content

Commit

Permalink
fix: Added commecnts and update example folder heirarchy (#19)
Browse files Browse the repository at this point in the history
* fix: Added commecnts and update example folder heirarchy

* fix: Update Workflows

* fix: source in example.tf
  • Loading branch information
13archit authored Aug 4, 2023
1 parent 7374cc4 commit d6b2727
Show file tree
Hide file tree
Showing 15 changed files with 114 additions and 212 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ updates:
reviewers:
- "approvers"
- package-ecosystem: "terraform" # See documentation for possible values
directory: "_example/" # Location of package manifests
directory: "_example/complete/" # Location of package manifests
schedule:
interval: "weekly"
# Add assignees
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/auto_assignee.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Auto Assign PRs
on:
pull_request:
types: [opened, reopened]
workflow_dispatch:
jobs:
assignee:
uses: clouddrove/github-shared-workflows/.github/workflows/auto_assignee.yml@master
secrets:
GITHUB: ${{ secrets.GITHUB }}
with:
assignees: 'clouddrove-ci'
21 changes: 10 additions & 11 deletions .github/workflows/readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,34 @@ on:
push:
branches:
- master

jobs:
readme-create:
readme:
name: 'readme-create'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v2.3.4
uses: actions/checkout@master

- name: 'Set up Python 3.7'
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: 'create readme'
uses: 'clouddrove/[email protected]'
with:
actions_subcommand: 'readme'
github_token: '${{ secrets.GITHUB}}'
github_token: '${{ secrets.GITHUB }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


- name: 'pre-commit check errors'
uses: pre-commit/action@v2.0.0
uses: pre-commit/action@v3.0.0
continue-on-error: true

- name: 'pre-commit fix errors'
uses: pre-commit/action@v2.0.0
- name: 'pre-commit fix erros'
uses: pre-commit/action@v3.0.0
continue-on-error: true

- name: 'push readme'
Expand All @@ -40,7 +39,7 @@ jobs:
with:
actions_subcommand: 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 'Slack Notification'
uses: clouddrove/action-slack@v2
Expand All @@ -51,4 +50,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
if: always()
if: always()
83 changes: 0 additions & 83 deletions .github/workflows/terraform.yml

This file was deleted.

40 changes: 0 additions & 40 deletions .github/workflows/terratest.yml

This file was deleted.

11 changes: 11 additions & 0 deletions .github/workflows/tf-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: tf-checks
on:
push:
branches: [ master ]
pull_request:
workflow_dispatch:
jobs:
tf-checks-complete-example:
uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@master
with:
working_directory: './_example/complete/'
11 changes: 11 additions & 0 deletions .github/workflows/tflint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: tf-lint
on:
push:
branches: [ master ]
pull_request:
workflow_dispatch:
jobs:
tf-lint:
uses: clouddrove/github-shared-workflows/.github/workflows/tf-lint.yml@master
secrets:
GITHUB: ${{ secrets.GITHUB }}
2 changes: 1 addition & 1 deletion .github/workflows/tfsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ jobs:
uses: clouddrove/github-shared-workflows/.github/workflows/tfsec.yml@master
secrets: inherit
with:
working_directory: '.'
working_directory: '.'
4 changes: 4 additions & 0 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ badges:
image: "https://github.com/clouddrove/terraform-aws-iam-role/actions/workflows/terraform.yml/badge.svg"
url: "https://github.com/clouddrove/terraform-aws-iam-role/actions/workflows/terraform.yml"

prerequesties:
- name: Terraform 1.5.4
url: https://learn.hashicorp.com/terraform/getting-started/install.html

# description of this project
description: |-
Terraform module to create Iam role resource on AWS.
Expand Down
45 changes: 45 additions & 0 deletions _example/complete/example.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
provider "aws" {
region = "eu-west-1"
}

##-----------------------------------------------------------------------------
## IAM role module call.
##-----------------------------------------------------------------------------
module "iam-role" {
source = "./../../"
name = "iam"
environment = "test"
assume_role_policy = data.aws_iam_policy_document.default.json
policy_enabled = true
policy = data.aws_iam_policy_document.iam-policy.json
}

##-----------------------------------------------------------------------------
## Data block to create IAM policy.
##-----------------------------------------------------------------------------
data "aws_iam_policy_document" "default" {
statement {
effect = "Allow"
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
}
}

##-----------------------------------------------------------------------------
## Data block to create IAM policy.
##-----------------------------------------------------------------------------
data "aws_iam_policy_document" "iam-policy" {
statement {
actions = [
"ssm:UpdateInstanceInformation",
"ssmmessages:CreateControlChannel",
"ssmmessages:CreateDataChannel",
"ssmmessages:OpenControlChannel",
"ssmmessages:OpenDataChannel"]
effect = "Allow"
resources = ["*"]
}
}
File renamed without changes.
40 changes: 0 additions & 40 deletions _example/example.tf

This file was deleted.

31 changes: 16 additions & 15 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
## Managed By : CloudDrove
## Copyright @ CloudDrove. All Right Reserved.
# Managed By : CloudDrove
# Copyright @ CloudDrove. All Right Reserved.

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

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

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

# Module : Iam Role Policy
# Description : Terraform module to create IAm role policy resource on AWS to attach with Iam Role.
##-----------------------------------------------------------------------------
## Below resource will attach IAM policy to above created IAM role.
##-----------------------------------------------------------------------------
resource "aws_iam_role_policy_attachment" "default" {
count = var.enabled && var.policy_enabled && var.policy_arn != "" ? 1 : 0
role = aws_iam_role.default.*.id[0]

count = var.enabled && var.policy_enabled && var.policy_arn != "" ? 1 : 0
role = aws_iam_role.default.*.id[0]
policy_arn = var.policy_arn
}
Loading

0 comments on commit d6b2727

Please sign in to comment.