Skip to content

Commit

Permalink
Merge pull request #1 from clouddrove/CD-90
Browse files Browse the repository at this point in the history
Cd 90
  • Loading branch information
Nikita Dugar authored Dec 28, 2019
2 parents 1d25ecb + d9e6c49 commit 8d1931a
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 19 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: 'Terraform GitHub Actions'
on:
- pull_request

jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
steps:

- name: 'Checkout'
uses: actions/checkout@master

- name: 'Terraform Format'
uses: clouddrove/[email protected]
with:
actions_subcommand: 'fmt'

- name: 'Terraform Init'
uses: clouddrove/[email protected]
with:
actions_subcommand: 'init'
tf_actions_working_dir: ./_example

- name: Configure AWS Credentials
uses: clouddrove/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2

- name: 'Terratest'
uses: clouddrove/[email protected]
with:
actions_subcommand: 'terratest'
tf_actions_working_dir: ./_test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 'Slack Notification'
uses: clouddrove/action-slack@v2
with:
status: ${{ job.status }}
fields: repo,author
author_name: 'Clouddrove'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} # required
if: always()
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Terraform AWS IAM Role
</h1>

<p align="center" style="font-size: 1.2rem;">
<p align="center" style="font-size: 1.2rem;">
Terraform module to create Iam role resource on AWS.
</p>

Expand Down Expand Up @@ -38,7 +38,7 @@
<hr>


We eat, drink, sleep and most importantly love **DevOps**. We are working towards stratergies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy <b>Bigger problems are always solved by breaking them into smaller manageable problems</b>. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller <b>connected yet manageable pieces</b> within the infrastructure.
We eat, drink, sleep and most importantly love **DevOps**. We are working towards stratergies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy <b>Bigger problems are always solved by breaking them into smaller manageable problems</b>. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller <b>connected yet manageable pieces</b> within the infrastructure.

This module is basically combination of [Terraform open source](https://www.terraform.io/) and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.

Expand All @@ -49,7 +49,7 @@ We have [*fifty plus terraform modules*][terraform_modules]. A few of them are c

## Prerequisites

This module has a few dependencies:
This module has a few dependencies:

- [Terraform 0.12](https://learn.hashicorp.com/terraform/getting-started/install.html)
- [Go](https://golang.org/doc/install)
Expand All @@ -72,12 +72,12 @@ This module has a few dependencies:
Here is an example of how you can use this module in your inventory structure:
```hcl
module "iam-role" {
source = "git::https://github.com/clouddrove/terraform-aws-iam-role.git?ref=tags/0.12.0"
source = "git::https://github.com/clouddrove/terraform-aws-iam-role.git?ref=tags/0.12.1"
name = "iam-role"
application = "clouddrove"
environment = "test"
label_order = ["environment", "name", "application"]
label_order = ["environment", "application", "name"]
assume_role_policy = data.aws_iam_policy_document.default.json
policy_enabled = true
Expand Down Expand Up @@ -146,7 +146,7 @@ Here is an example of how you can use this module in your inventory structure:


## Testing
In this module testing is performed with [terratest](https://github.com/gruntwork-io/terratest) and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a [GO environment](https://golang.org/doc/install) in your system.
In this module testing is performed with [terratest](https://github.com/gruntwork-io/terratest) and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a [GO environment](https://golang.org/doc/install) in your system.

You need to run the following command in the testing folder:
```hcl
Expand All @@ -155,7 +155,7 @@ You need to run the following command in the testing folder:



## Feedback
## Feedback
If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/terraform-aws-iam-role/issues), or feel free to drop us an email at [[email protected]](mailto:[email protected]).

If you have found it worth your time, go ahead and give us a ★ on [our GitHub](https://github.com/clouddrove/terraform-aws-iam-role)!
Expand Down
4 changes: 2 additions & 2 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ usage : |-
Here is an example of how you can use this module in your inventory structure:
```hcl
module "iam-role" {
source = "git::https://github.com/clouddrove/terraform-aws-iam-role.git?ref=tags/0.12.0"
source = "git::https://github.com/clouddrove/terraform-aws-iam-role.git?ref=tags/0.12.1"
name = "iam-role"
application = "clouddrove"
environment = "test"
label_order = ["environment", "name", "application"]
label_order = ["environment", "application", "name"]
assume_role_policy = data.aws_iam_policy_document.default.json
policy_enabled = true
Expand Down
12 changes: 6 additions & 6 deletions _example/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ provider "aws" {
}

module "iam-role" {
source = "git::https://github.com/clouddrove/terraform-aws-iam-role.git?ref=tags/0.12.0"
source = "./../"

name = "iam-role"
application = "clouddrove"
environment = "test"
label_order = ["application", "name", "name"]
name = "iam-role"
application = "clouddrove"
environment = "test"
label_order = ["environment", "application", "name"]

assume_role_policy = data.aws_iam_policy_document.default.json

Expand All @@ -34,7 +34,7 @@ data "aws_iam_policy_document" "iam-policy" {
"ssmmessages:CreateControlChannel",
"ssmmessages:CreateDataChannel",
"ssmmessages:OpenControlChannel",
"ssmmessages:OpenDataChannel" ]
"ssmmessages:OpenDataChannel"]
effect = "Allow"
resources = ["*"]
}
Expand Down
2 changes: 1 addition & 1 deletion _test/iam_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ func Test(t *testing.T) {
Arn := strings.Join(terraform.OutputList(t, terraformOptions, "arn"),"")

// Check that we get back the outputs that we expect
assert.Equal(t, "test-iam-role-clouddrove", Tags["Name"])
assert.Equal(t, "test-clouddrove-iam-role", Tags["Name"])
assert.Contains(t, Arn, "arn:aws:iam")
}
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ resource "aws_iam_role" "default" {
# Module : Iam Role Policy
# Description : Terraform module to create IAm role policy resource on AWS to attach with Iam Role.
resource "aws_iam_role_policy" "default" {
count = var.enabled && var.policy_enabled ? 1 : 0
name = format("%s-policy", module.labels.id)
role = aws_iam_role.default.*.id[0]
count = var.enabled && var.policy_enabled ? 1 : 0
name = format("%s-policy", module.labels.id)
role = aws_iam_role.default.*.id[0]
policy = var.policy
}

0 comments on commit 8d1931a

Please sign in to comment.