Skip to content

Commit

Permalink
fix: added versions.tf and updated vpc tag
Browse files Browse the repository at this point in the history
  • Loading branch information
anmolnagpal committed Jun 5, 2023
1 parent 5fef603 commit 25693fb
Show file tree
Hide file tree
Showing 11 changed files with 162 additions and 122 deletions.
1 change: 0 additions & 1 deletion .github/workflows/readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,3 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
if: always()

4 changes: 3 additions & 1 deletion .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ jobs:
- ${{ needs.versionExtract.outputs.minVersion }}
- ${{ needs.versionExtract.outputs.maxVersion }}
directory:
- _example/
- _example/anomaly_example/
- _example/basic_example/
- _example/expression_example/

steps:
- name: Checkout
Expand Down
36 changes: 8 additions & 28 deletions .github/workflows/terratest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,27 @@ on:
types: [labeled]

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

- name: 'Checkout'
uses: actions/checkout@master
uses: actions/checkout@v2.3.4

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

- name: 'Terratest anomaly_example'
if: ${{ github.event.label.name == 'terratest' }}
- name: 'terratest'
uses: 'clouddrove/github-actions@v9.0.2'
with:
actions_subcommand: 'terratest'
tf_actions_working_dir: '_test/anomaly_example'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 'Terratest basic_example'
if: ${{ github.event.label.name == 'terratest' }}
uses: 'clouddrove/github-actions@v9.0.2'
with:
actions_subcommand: 'terratest'
tf_actions_working_dir: '_test/basic_example'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 'Terratest expression_example'
if: ${{ github.event.label.name == 'terratest' }}
uses: 'clouddrove/github-actions@v9.0.2'
with:
actions_subcommand: 'terratest'
tf_actions_working_dir: '_test/expression_example'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ github.event.label.name == 'terratest' }}
tf_actions_working_dir: '_test'

- name: 'Slack Notification'
uses: clouddrove/action-slack@v2
Expand All @@ -57,4 +37,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
if: always()
if: always()
126 changes: 73 additions & 53 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,29 @@ usage: |-
module "alarm" {
source = "clouddrove/cloudwatch-alarms/aws"
version = "1.3.0"
name = "alarm"
environment = "test"
label_order = ["name", "environment"]
alarm_name = "cpu-alarm"
comparison_operator = "LessThanThreshold"
evaluation_periods = 2
metric_name = "CPUUtilization"
namespace = "AWS/EC2"
period = "60"
statistic = "Average"
threshold = "40"
alarm_description = "This metric monitors ec2 cpu utilization"
alarm_actions = ["arn:aws:sns:eu-west-1:xxxxxxxxxxx:test"]
name = "alarm"
environment = "test"
label_order = ["name", "environment"]
alarm_name = "cpu-alarm"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = 2
metric_name = "CPUUtilization"
namespace = "AWS/EC2"
period = 60
statistic = "Average"
threshold = 40
alarm_description = "This metric monitors ec2 cpu utilization"
alarm_actions = []
actions_enabled = true
insufficient_data_actions = []
ok_actions = []
dimensions = {
instance_id = "i-xxxxxxxxxxxxx"
dimensions = {
instance_id = module.ec2.instance_id[0]
}
}
```
Expand All @@ -72,74 +76,90 @@ usage: |-
module "alarm" {
source = "clouddrove/cloudwatch-alarms/aws"
version = "1.3.0"
name = "alarm"
environment = "test"
label_order = ["name", "environment"]
alarm_name = "cpu-alarm"
comparison_operator = "GreaterThanUpperThreshold"
evaluation_periods = 2
threshold_metric_id = "e1"
query_expressions = [{
name = "alarm"
environment = "test"
label_order = ["name", "environment"]
alarm_name = "cpu-alarm"
comparison_operator = "GreaterThanUpperThreshold"
evaluation_periods = 2
threshold_metric_id = "e1"
query_expressions = [{
id = "e1"
expression = "ANOMALY_DETECTION_BAND(m1)"
label = "CPUUtilization (Expected)"
return_data = "true"
}]
query_metrics = [{
query_metrics = [{
id = "m1"
return_data = "true"
metric_name = "CPUUtilization"
namespace = "AWS/EC2"
period = "120"
stat = "Average"
unit = "Count"
dimensions = {
dimensions = {
InstanceId = module.ec2.instance_id[0]
}
}]
alarm_description = "This metric monitors ec2 cpu utilization"
alarm_actions = []
alarm_description = "This metric monitors ec2 cpu utilization"
alarm_actions = []
actions_enabled = true
insufficient_data_actions = []
ok_actions = []
}
}
```
### Epression Example
```hcl
module "alarm" {
source = "clouddrove/cloudwatch-alarms/aws"
version = "1.3.0"
name = "alarm"
environment = "test"
label_order = ["name", "environment"]
expression_enabled = true
alarm_name = "cpu-alarm"
comparison_operator = "GreaterThanUpperThreshold"
evaluation_periods = 2
threshold = 40
query_expressions = [{
name = "alarm"
environment = "test"
label_order = ["name", "environment"]
expression_enabled = true
alarm_name = "cpu-alarm"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = 2
threshold = 40
query_expressions = [{
id = "e1"
expression = "ANOMALY_DETECTION_BAND(m1)"
label = "CPUUtilization (Expected)"
expression = "m2/m1*100"
label = "Error Rate"
return_data = "true"
}]
query_metrics = [{
id = "m1"
return_data = "true"
metric_name = "CPUUtilization"
namespace = "AWS/EC2"
period = "120"
stat = "Average"
unit = "Count"
dimensions = {
InstanceId = module.ec2.instance_id[0]
}
query_metrics = [
{
id = "m1"
metric_name = "RequestCount"
namespace = "AWS/ApplicationELB"
period = "120"
stat = "Sum"
unit = "Count"
return_data = null
dimensions = {
LoadBalancer = "app/web"
}
}, {
id = "m2"
metric_name = "HTTPCode_ELB_5XX_Count"
namespace = "AWS/ApplicationELB"
period = "120"
stat = "Sum"
unit = "Count"
return_data = null
dimensions = {
LoadBalancer = "app/web"
}
}]
alarm_description = "This metric monitors ec2 cpu utilization"
alarm_actions = []
alarm_description = "This metric monitors ec2 cpu utilization"
alarm_actions = []
actions_enabled = true
insufficient_data_actions = []
ok_actions = []
}
}
```
21 changes: 21 additions & 0 deletions _example/anomaly_example/example.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
##---------------------------------------------------------------------------------------------------------------------------
## Provider block added, Use the Amazon Web Services (AWS) provider to interact with the many resources supported by AWS.
##--------------------------------------------------------------------------------------------------------------------------
provider "aws" {
region = "eu-west-1"
}

##---------------------------------------------------------------------------------------------------------------------------
## A VPC is a virtual network that closely resembles a traditional network that you'd operate in your own data center.
##--------------------------------------------------------------------------------------------------------------------------
module "vpc" {
source = "clouddrove/vpc/aws"
version = "1.3.1"
Expand All @@ -13,6 +19,9 @@ module "vpc" {
cidr_block = "172.16.0.0/16"
}

##-----------------------------------------------------
## A subnet is a range of IP addresses in your VPC.
##-----------------------------------------------------
module "public_subnets" {
source = "clouddrove/subnet/aws"
version = "1.3.0"
Expand All @@ -30,6 +39,9 @@ module "public_subnets" {
igw_id = module.vpc.igw_id
}

##-----------------------------------------------------
## An AWS security group acts as a virtual firewall for incoming and outgoing traffic with http-https.
##-----------------------------------------------------
module "http-https" {
source = "clouddrove/security-group/aws"
version = "1.3.0"
Expand All @@ -43,6 +55,9 @@ module "http-https" {
allowed_ports = [80, 443]
}

##-----------------------------------------------------
## An AWS security group acts as a virtual firewall for incoming and outgoing traffic with ssh.
##-----------------------------------------------------
module "ssh" {
source = "clouddrove/security-group/aws"
version = "1.3.0"
Expand All @@ -56,6 +71,9 @@ module "ssh" {
allowed_ports = [22]
}

##-----------------------------------------------------
## Amazon EC2 provides cloud hosted virtual machines, called "instances", to run applications.
##-----------------------------------------------------
module "ec2" {
source = "clouddrove/ec2/aws"
version = "1.3.0"
Expand Down Expand Up @@ -83,6 +101,9 @@ module "ec2" {
user_data = "./_bin/user_data.sh"
}

##-----------------------------------------------------------------------------
## alarm module call.
##-----------------------------------------------------------------------------
module "alarm" {
source = "../../"

Expand Down
21 changes: 21 additions & 0 deletions _example/basic_example/example.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
##---------------------------------------------------------------------------------------------------------------------------
## Provider block added, Use the Amazon Web Services (AWS) provider to interact with the many resources supported by AWS.
##--------------------------------------------------------------------------------------------------------------------------
provider "aws" {
region = "eu-west-1"
}

##---------------------------------------------------------------------------------------------------------------------------
## A VPC is a virtual network that closely resembles a traditional network that you'd operate in your own data center.
##--------------------------------------------------------------------------------------------------------------------------
module "vpc" {
source = "clouddrove/vpc/aws"
version = "1.3.1"
Expand All @@ -14,6 +20,9 @@ module "vpc" {
cidr_block = "172.16.0.0/16"
}

##-----------------------------------------------------
## A subnet is a range of IP addresses in your VPC.
##-----------------------------------------------------
module "public_subnets" {
source = "clouddrove/subnet/aws"
version = "1.3.0"
Expand All @@ -31,6 +40,9 @@ module "public_subnets" {
igw_id = module.vpc.igw_id
}

##-----------------------------------------------------
## An AWS security group acts as a virtual firewall for incoming and outgoing traffic with http-https.
##-----------------------------------------------------
module "http-https" {
source = "clouddrove/security-group/aws"
version = "1.3.0"
Expand All @@ -45,6 +57,9 @@ module "http-https" {
allowed_ports = [80, 443]
}

##-----------------------------------------------------
## An AWS security group acts as a virtual firewall for incoming and outgoing traffic with ssh.
##-----------------------------------------------------
module "ssh" {
source = "clouddrove/security-group/aws"
version = "1.3.0"
Expand All @@ -59,6 +74,9 @@ module "ssh" {
allowed_ports = [22]
}

##-----------------------------------------------------
## Amazon EC2 provides cloud hosted virtual machines, called "instances", to run applications.
##-----------------------------------------------------
module "ec2" {
source = "clouddrove/ec2/aws"
version = "1.3.0"
Expand All @@ -85,6 +103,9 @@ module "ec2" {
user_data = "./_bin/user_data.sh"
}

##-----------------------------------------------------------------------------
## alarm module call.
##-----------------------------------------------------------------------------
module "alarm" {
source = "../../"

Expand Down
11 changes: 0 additions & 11 deletions _example/basic_example/versions.tf

This file was deleted.

Loading

0 comments on commit 25693fb

Please sign in to comment.