Skip to content

Commit

Permalink
github action (#2)
Browse files Browse the repository at this point in the history
* github action

* github action

* github action
  • Loading branch information
Sohan authored and anmolnagpal committed Dec 29, 2019
1 parent 5a27fe4 commit 63256fd
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 21 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
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/github-actions@v2.0
with:
actions_subcommand: 'fmt'

- name: 'Terraform Init For fifo'
uses: clouddrove/github-actions@v2.0
with:
actions_subcommand: 'init'
tf_actions_working_dir: ./_example/fifo

- name: 'Terraform Init For standard'
uses: clouddrove/github-actions@v2.0
with:
actions_subcommand: 'init'
tf_actions_working_dir: ./_example/standard

- 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 For fifo'
uses: clouddrove/github-actions@v2.0
with:
actions_subcommand: 'plan'
tf_actions_working_dir: ./_example/fifo
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 'Terratest For standard'
uses: clouddrove/github-actions@v2.0
with:
actions_subcommand: 'terratest'
tf_actions_working_dir: ./_test/standard
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()
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,23 @@ Here are some examples of how you can use this module in your inventory structur
### FIFO Queue
```hcl
module "sqs" {
source = "git::https://github.com/clouddrove/terraform-aws-sqs.git?ref=tags/0.12.1"
source = "git::https://github.com/clouddrove/terraform-aws-sqs.git?ref=tags/0.12.2"
name = "sqs-fifo"
application = "clouddrove"
environment = "test"
label_order = ["environment", "name", "application"]
label_order = ["environment", "application", "name"]
fifo_queue = true
content_based_deduplication = true
}
```
### Standard Queue
```hcl
module "sqs" {
source = "git::https://github.com/clouddrove/terraform-aws-sqs.git?ref=tags/0.12.1"
source = "git::https://github.com/clouddrove/terraform-aws-sqs.git?ref=tags/0.12.2"
name = "sqs"
application = "clouddrove"
environment = "test"
label_order = ["environment", "name", "application"]
label_order = ["environment", "application", "name"]
delay_seconds = 90
max_message_size = 2048
message_retention_seconds = 86400
Expand All @@ -104,7 +104,7 @@ Here are some examples of how you can use this module in your inventory structur
identifiers = ["*"]
}
actions = ["sqs:SendMessage"]
resources = ["arn:aws:sqs:eu-west-1:xxxxxxxxx:test-sqs-clouddrove"]
resources = ["arn:aws:sqs:eu-west-1:xxxxxxxxx:test-clouddrove-sqs"]
}
}
```
Expand Down
10 changes: 5 additions & 5 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,23 @@ usage : |-
### FIFO Queue
```hcl
module "sqs" {
source = "git::https://github.com/clouddrove/terraform-aws-sqs.git?ref=tags/0.12.1"
source = "git::https://github.com/clouddrove/terraform-aws-sqs.git?ref=tags/0.12.2"
name = "sqs-fifo"
application = "clouddrove"
environment = "test"
label_order = ["environment", "name", "application"]
label_order = ["environment", "application", "name"]
fifo_queue = true
content_based_deduplication = true
}
```
### Standard Queue
```hcl
module "sqs" {
source = "git::https://github.com/clouddrove/terraform-aws-sqs.git?ref=tags/0.12.1"
source = "git::https://github.com/clouddrove/terraform-aws-sqs.git?ref=tags/0.12.2"
name = "sqs"
application = "clouddrove"
environment = "test"
label_order = ["environment", "name", "application"]
label_order = ["environment", "application", "name"]
delay_seconds = 90
max_message_size = 2048
message_retention_seconds = 86400
Expand All @@ -71,7 +71,7 @@ usage : |-
identifiers = ["*"]
}
actions = ["sqs:SendMessage"]
resources = ["arn:aws:sqs:eu-west-1:xxxxxxxxx:test-sqs-clouddrove"]
resources = ["arn:aws:sqs:eu-west-1:xxxxxxxxx:test-clouddrove-sqs"]
}
}
```
4 changes: 2 additions & 2 deletions _example/fifo/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ provider "aws" {
}

module "sqs" {
source = "git::https://github.com/clouddrove/terraform-aws-sqs.git?ref=tags/0.12.1"
source = "./../../"

name = "sqs-fifo"
application = "clouddrove"
environment = "test"
label_order = ["environment", "name", "application"]
label_order = ["environment", "application", "name"]

fifo_queue = true
content_based_deduplication = true
Expand Down
13 changes: 9 additions & 4 deletions _example/standard/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ provider "aws" {
region = "eu-west-1"
}

data "aws_caller_identity" "current" {}


module "sqs" {
source = "git::https://github.com/clouddrove/terraform-aws-sqs.git?ref=tags/0.12.1"
source = "./../../"

name = "sqs"
application = "clouddrove"
environment = "test"
label_order = ["environment", "name", "application"]
label_order = ["environment", "application", "name"]

delay_seconds = 90
max_message_size = 2048
Expand All @@ -26,7 +29,9 @@ data "aws_iam_policy_document" "document" {
type = "AWS"
identifiers = ["*"]
}
actions = ["sqs:SendMessage"]
resources = ["arn:aws:sqs:eu-west-1:xxxxxxxxx:test-sqs-clouddrove"]
actions = ["sqs:SendMessage"]
resources = [
format("arn:aws:sqs:eu-west-1:%s:test-clouddrove-sqs", data.aws_caller_identity.current.account_id)
]
}
}
2 changes: 1 addition & 1 deletion _test/fifo/sqs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ func Test(t *testing.T) {
Tags := terraform.OutputMap(t, terraformOptions, "tags")

// Check that we get back the outputs that we expect
assert.Equal(t, "test-sqs-fifo-clouddrove", Tags["Name"])
assert.Equal(t, "test-clouddrove-sqs-fifo", Tags["Name"])
assert.Contains(t, Arn, "arn:aws:sqs")
}
2 changes: 1 addition & 1 deletion _test/standard/sqs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ func Test(t *testing.T) {
Tags := terraform.OutputMap(t, terraformOptions, "tags")

// Check that we get back the outputs that we expect
assert.Equal(t, "test-sqs-clouddrove", Tags["Name"])
assert.Equal(t, "test-clouddrove-sqs", Tags["Name"])
assert.Contains(t, Arn, "arn:aws:sqs")
}
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# for resources. You can use terraform-labels to implement a strict naming
# convention.
module "labels" {
source = "git::https://github.com/clouddrove/terraform-labels.git"
source = "git::https://github.com/clouddrove/terraform-labels.git?ref=tags/0.12.0"

name = var.name
application = var.application
Expand Down
4 changes: 2 additions & 2 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Module : SQS
# Description : Terraform module to create SQS resource on AWS for managing queue.
output "id" {
value = join("", aws_sqs_queue.default.*.id)
value = join("", aws_sqs_queue.default.*.id)
description = "The URL for the created Amazon SQS queue."
}

output "arn" {
value = join("", aws_sqs_queue.default.*.arn)
value = join("", aws_sqs_queue.default.*.arn)
description = "The ARN of the SQS queue."
}

Expand Down

0 comments on commit 63256fd

Please sign in to comment.