Skip to content
This repository was archived by the owner on Jun 30, 2023. It is now read-only.

Commit 79d885c

Browse files
umarali-nagoorhkantare
authored andcommitted
Added terratest framework
1 parent 5c98552 commit 79d885c

File tree

17 files changed

+479
-148
lines changed

17 files changed

+479
-148
lines changed

.github/workflows/test.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: "test-scheduler"
2+
3+
on:
4+
workflow_dispatch:
5+
6+
7+
schedule:
8+
- cron: '*/30 5 * * *' # triggers the workflow every day at 5:30 UTC
9+
10+
# ┌───────────── minute (0 - 59)
11+
# │ ┌───────────── hour (0 - 23)
12+
# │ │ ┌───────────── day of the month (1 - 31)
13+
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
14+
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
15+
# │ │ │ │ │
16+
# │ │ │ │ │
17+
# │ │ │ │ │
18+
# * * * * *
19+
20+
jobs:
21+
continuous-tests:
22+
name: Run Test cases
23+
runs-on: ubuntu-latest
24+
steps:
25+
-
26+
name: checkout # action checks-out your repository under $GITHUB_WORKSPACE, so your workflow can access it.
27+
uses: actions/checkout@v2
28+
29+
- uses: actions/setup-go@v2
30+
with:
31+
go-version: 1.15
32+
33+
- name: Install dependencies
34+
run: |
35+
go get -u "github.com/gruntwork-io/terratest/modules/random"
36+
go get -u "github.com/gruntwork-io/terratest/modules/terraform"
37+
38+
-
39+
name: setup terraform
40+
uses: hashicorp/setup-terraform@v1 # sets up Terraform CLI in your GitHub Actions workflow
41+
with:
42+
terraform_version: 0.13.0
43+
44+
- name: Run Test
45+
working-directory: test
46+
run: go test -v ./...
47+
env:
48+
IC_API_KEY: ${{ secrets.ACCESS_KEY }}

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# IBM Cloud Observability - Terraform Module
22

33
This is a collection of modules that make it easier to provision observability services like logging, monitor and activity tracker on IBM Cloud Platform:
4-
* [logging-logdna](modules/logging-logdna)
5-
* [monitoring-sysdig](modules/monitoring-sysdig)
6-
* [activity-tracker-logdna](modules/activity-tracker-logdna)
4+
5+
* logging-logdna
6+
* monitoring-sysdig
7+
* activity-tracker-logdna
78

89
## Compatibility
910

examples/activity-tracker-logdna-instance/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,12 @@ module "activity-tracker_instance" {
4646

4747
NOTE: We can set the create, update and delete timeouts as string. For e.g say we want to set 15 minutes timeout then the value should be "15m".
4848

49+
## Usage
4950

51+
To create an infrastructure run the following command
52+
53+
`terraform apply -var-file="input.tfvars"`
54+
55+
Similarly to remove an infrastructure run the following command
56+
57+
`terraform destroy -var-file="input.tfvars"`

examples/logging-logdna-hippa-instance/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,16 @@ module "logdna_instance" {
4545
| tags | Tags that should be applied to the service | list(string) | n/a | no |
4646
| resource_key_tags | Tags that should be applied to the resource key | list(string) | n/a | no |
4747

48+
## NOTE
49+
50+
To attach a key to logdna instance enable it by setting `bind_resource_key` argument to true (which is by default false). And set the `resource_key_name` and `role` parameters accordingly (which are by deafult empty) in variables.tf file.
51+
52+
## Usage
53+
54+
To create an infrastructure run the following command
55+
56+
`terraform apply`
57+
58+
Similarly to remove an infrastructure run the following command
59+
60+
`terraform destroy`

examples/logging-logdna-hippa-instance/variables.tf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
#####################################################
55

66
variable "bind_resource_key" {
7-
description = "Bool(0/1) Flag indicating that logdna instance key should be bind to logdna instance"
7+
description = "Flag indicating that key should be bind to logdna hippa instance"
88
type = bool
9+
default = false
910
}
1011

1112
variable "service_name" {
@@ -45,11 +46,13 @@ variable "resource_key_tags" {
4546
variable "resource_key_name" {
4647
description = "Name of the instance key"
4748
type = string
49+
default = ""
4850
}
4951

5052
variable "role" {
51-
description = "plan type"
53+
description = "Type of role"
5254
type = string
55+
default = ""
5356
}
5457

5558
variable "resource_group" {

examples/logging-logdna-instance/README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,20 @@ module "logdna_instance" {
5353
| delete_timeout | Timeout duration for delete | string | n/a | no |
5454

5555

56-
NOTE: We can set the create, update and delete timeouts as string. For e.g say we want to set 15 minutes timeout then the value should be "15m".
56+
## NOTE:
57+
58+
We can set the create, update and delete timeouts as string. For e.g say we want to set 15 minutes timeout then the value should be "15m".
59+
60+
## NOTE
61+
62+
To attach a key to logdna instance enable it by setting `bind_resource_key` argument to true (which is by default false). And set the `resource_key_name` and `role` parameters accordingly (which are by deafult empty) in variables.tf file.
63+
64+
## Usage
65+
66+
To create an infrastructure run the following command
67+
68+
`terraform apply -var-file="input.tfvars"`
69+
70+
Similarly to remove an infrastructure run the following command
71+
72+
`terraform destroy -var-file="input.tfvars"`

examples/logging-logdna-instance/variables.tf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
#####################################################
55

66
variable "bind_resource_key" {
7-
description = "Flag(0/1) indicating that logdna instance key should be bind to logdna instance"
7+
description = "Flag indicating that key should be bind to logdna instance"
88
type = bool
9+
default = false
910
}
1011

1112
variable "service_name" {
@@ -69,11 +70,13 @@ variable "resource_key_tags" {
6970
variable "resource_key_name" {
7071
description = "Name of the instance key"
7172
type = string
73+
default = ""
7274
}
7375

7476
variable "role" {
75-
description = "plan type"
77+
description = "Type of role"
7678
type = string
79+
default = ""
7780
}
7881

7982
variable "resource_group" {

examples/sysdig-downtime-alert/README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ resource "sysdig_monitor_alert_downtime" "sample" {
3939
| trigger_time | Threshold of time for status to stabilize until alert is fired. | number | n/a | yes |
4040
| pct | Below of this percentage of downtime the alert will be triggered.| number | 100 | no |
4141

42-
## To Create
42+
## Note
4343

44-
terraform apply -var-file="input.tfvars"
44+
All optional fields are given value `null` in varaible.tf file. User can configure the same by overwriting with appropriate values.
4545

46-
## To Destroy
46+
## Usage
4747

48-
terraform destroy -var-file="input.tfvars"
48+
To create an infrastructure run the following command
4949

50-
## Note
50+
`terraform apply -var-file="input.tfvars"`
51+
52+
Similarly to remove an infrastructure run the following command
5153

52-
All optional fields are given value `null` in varaible.tf file. User can configure the same by overwriting with appropriate values.
54+
`terraform destroy -var-file="input.tfvars"`

examples/sysdig-iam-integration/README.md

Lines changed: 83 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,109 @@
22

33
This module is used to grant a user or service ID permissions to work with the IBM Cloud Monitoring with Sysdig service:
44

5+
56
## Example Usage
67
```
78
provider "ibm" {
89
}
910
1011
module "access_group" {
11-
source = "terraform-ibm-modules/iam/ibm//modules/access-group"
12+
// Uncomment following line to point the source to registry level module
13+
//source = "terraform-ibm-modules/iam/ibm//modules/access-group"
1214
13-
name = var.name
14-
tags = var.ag_tags
15-
description = var.description
16-
}
15+
source = "../../modules/access-group"
1716
18-
module "access_group_policy" {
19-
source = "terraform-ibm-modules/iam/ibm//modules/access-group-policy"
20-
access_group_id = module.access_group.access_group_id
21-
roles = var.roles
22-
tags = var.ag_policy_tags
23-
resources = var.resources
24-
account_management = var.account_management
25-
}
17+
######### access group ######################
18+
name = var.name
19+
tags = var.tags
20+
description = var.description
21+
provision = var.provision
22+
23+
######### access group members ##############
24+
ibm_ids = var.ibm_ids
25+
service_ids = var.service_ids
26+
27+
######### access group policy ###############
28+
policies = var.policies
2629
27-
module "access_group_members" {
28-
source = "terraform-ibm-modules/iam/ibm//modules/access-group-members"
29-
access_group_id = module.access_group.access_group_id
30-
ibm_ids = var.ibm_ids
31-
service_ids = var.service_ids
30+
######### access group dynamic rule #########
31+
dynamic_rules = var.dynamic_rules
3232
}
33+
3334
```
3435

35-
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
36+
## NOTE:
37+
38+
If we want to make use of a particular version of module, then set the argument "version" to respective module version.
39+
3640
## Inputs
3741

42+
| Name | Description | Type | Default | Required |
43+
|---------------------------|------------------------------------------------------------------|:-------------|:------- |:---------|
44+
| name | A descriptive name used to identify the access group | string | n/a | yes |
45+
| provision | Used to decide whether to create a new access group or not | bool | true | no |
46+
| description | The description of the access group. | string | n/a | no |
47+
| tags | Tags that should be applied to the service | list(string) | n/a | no |
48+
| service_ids | List of service IDS add to access group. | string | n/a | no |
49+
| ibm_ids | IBM IDs that you want to add to or remove from the access group. | list(string) | n/a | no |
50+
| policies | List of access group of policies. | list(any) | n/a | yes |
51+
| dynamic_rules | List of dynamic rules to add to access group. | list(any) | n/a | yes |
52+
53+
54+
## policies inputs
55+
56+
| Name | Description | Type | Default | Required |
57+
|---------------------|------------------------------------------------------------------|:-------------|:------- :--------- |
58+
| roles | list of roles. | list(string) | n/a | yes |
59+
| tags | list of tags that you want to add to the access group policy. | list(string) | n/a | no |
60+
| account_management | Gives access to all account management services if set to true | bool | false | no |
61+
| resources | A nested block describes the resource of this policy | string | n/a | no |
62+
| resource_attributes | A nested block describes the resource attributes of the policy | string | n/a | no |
63+
64+
65+
## resources inputs
66+
67+
| Name | Description | Type | Default | Required|
68+
|-------------------------------|------------------------------------------------------------------|:-------------|:------- :---------|
69+
| service | service name that you want to include in your policy definition | string | n/a | no |
70+
| resource_instance_id | ID of resource instance of the policy definition. | string | n/a | no |
71+
| region | Region of the policy definition | string | n/a | no |
72+
| resource_type | Resource type of the policy definition. | string | n/a | no |
73+
| resource | Resource of the policy definition. | string | n/a | no |
74+
| resource_group_id | ID of the resource group | string | n/a | no |
75+
| attributes | Set resource attributes in the form of name=value,name=value | string | n/a | no |
76+
77+
## resource_attributes inputs
78+
79+
| Name | Description | Type | Default | Required|
80+
|-------------------------------|------------------------------------------------------------------|:--------|:------------|:--------|
81+
| name | Name of the Attribute. | string | n/a | yes |
82+
| value | Value of the Attribute. | string | n/a | yes |
83+
| operator | Operator of the Attribute | string | stringEquals| no |
84+
85+
## dynamic_rules inputs
86+
87+
| name | Key of a map taken as name of the rule | string | n/a | yes |
88+
| expiration | The expiration in hours. | number | n/a | yes |
89+
| identity_provider | URI for your identity provider.. | string | n/a | yes |
90+
| conditions | A nested block containes list of conditions that the rule must satisfy | list(map) | n/a | yes |
91+
92+
## conditions Inputs
93+
94+
| Name | Description | Type | Default | Required |
95+
|----------------------|------------------------------------------------------------------|----------|---------|----------|
96+
| claim | The key value to evaluate the condition against. | String | n/a | yes |
97+
| operator | The operation to perform on the claim. | String | n/a | yes |
98+
| value | Value that the claim is compared by using the conditions.operator| String | n/a | yes |
3899

39-
| Name | Description | Type | Default | Required |
40-
|--------------------|------------------------------------------------------------------|:-------------|:------- |:---------|
41-
| name | A descriptive name used to identify the access group | string | n/a | yes |
42-
| description | The description of the access group. | string | n/a | no |
43-
| ag_tags | Tags that should be applied to the service | list(string) | n/a | no |
44-
| roles | list of roles. | list(string) | n/a | yes |
45-
| ag_policy_tags | list of tags that you want to add to the access group policy. | list(string) | n/a | no |
46-
| account_management | Gives access to all account management services if set to true | bool | false | no |
47-
| resources | A nested block describes the resource of this policy | string | n/a | no |
48-
| service_ids | List of service IDS add to access group. | string | n/a | no |
49-
| ibm_ids | IBM IDs that you want to add to or remove from the access group. | list(string) | n/a | no |
50-
51-
## Resources Inputs
52-
53-
| Name | Description | Type | Default | Required |
54-
|-------------------------------|------------------------------------------------------------------|:-------------|:------- |:---------|
55-
| service | service name that you want to include in your policy definition | string | n/a | no |
56-
| resource_instance_id | ID of resource instance of the policy definition. | string | n/a | no |
57-
| region | Region of the policy definition | string | n/a | no |
58-
| resource_type | Resource type of the policy definition. | string | n/a | no |
59-
| resource | Resource of the policy definition. | string | n/a | no |
60-
| resource_group_id | ID of the resource group | string | n/a | no |
61-
| attributes | Set resource attributes in the form of name=value,name=value | string | n/a | no |
100+
Note: For more information on input varaibles refer https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_access_group_policy
62101

63102
## Usage
64103

65-
To create access members group run the following command
104+
To create an infrastructure run the following command
66105

67106
`terraform apply -var-file="input.tfvars"`
68107

69-
Similarly to to remove the access group members run the command
108+
Similarly to remove an infrastructure run the following command
70109

71110
`terraform destroy -var-file="input.tfvars"`

0 commit comments

Comments
 (0)