Skip to content

Commit

Permalink
Convert to TF 0.12. Add tests. Add Codefresh test pipeline (#53)
Browse files Browse the repository at this point in the history
* Convert to TF 0.12. Add tests. Add Codefresh test pipeline

* Convert to TF 0.12. Add tests. Add Codefresh test pipeline

* Convert to TF 0.12. Add tests. Add Codefresh test pipeline

* Convert to TF 0.12. Add tests. Add Codefresh test pipeline

* Convert to TF 0.12. Add tests. Add Codefresh test pipeline

* Convert to TF 0.12. Add tests. Add Codefresh test pipeline
  • Loading branch information
aknysh authored Jul 5, 2019
1 parent b0586fb commit 946a7a2
Show file tree
Hide file tree
Showing 29 changed files with 981 additions and 341 deletions.
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

89 changes: 45 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[![Cloud Posse][logo]](https://cpco.io/homepage)

# terraform-aws-rds-cluster [![Build Status](https://travis-ci.org/cloudposse/terraform-aws-rds-cluster.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-aws-rds-cluster) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-rds-cluster.svg)](https://github.com/cloudposse/terraform-aws-rds-cluster/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
# terraform-aws-rds-cluster [![Codefresh Build Status](https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-aws-rds-cluster?type=cf-1)](https://g.codefresh.io/public/accounts/cloudposse/pipelines/5d1eb949a7e22e49dc7ea7c9) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-rds-cluster.svg)](https://github.com/cloudposse/terraform-aws-rds-cluster/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)


Terraform module to provision an [`RDS Aurora`](https://aws.amazon.com/rds/aurora) cluster for MySQL or Postgres.
Expand Down Expand Up @@ -102,7 +102,7 @@ module "rds_cluster_aurora_mysql_serverless" {
max_capacity = 256
min_capacity = 2
seconds_until_auto_pause = 300
},
}
]
}
```
Expand Down Expand Up @@ -150,11 +150,11 @@ module "rds_cluster_aurora_mysql" {
},
{
name = "collation_connection"
value = "uft8_bin"
value = "utf8_bin"
},
{
name = "collation_server"
value = "uft8_bin"
value = "utf8_bin"
},
{
name = "lower_case_table_names"
Expand All @@ -165,7 +165,7 @@ module "rds_cluster_aurora_mysql" {
name = "skip-character-set-client-handshake"
value = "1"
apply_method = "pending-reboot"
},
}
]
}
```
Expand All @@ -176,12 +176,12 @@ module "rds_cluster_aurora_mysql" {
# create IAM role for monitoring
resource "aws_iam_role" "enhanced_monitoring" {
name = "rds-cluster-example-1"
assume_role_policy = "${data.aws_iam_policy_document.enhanced_monitoring.json}"
assume_role_policy = data.aws_iam_policy_document.enhanced_monitoring.json
}
# Attach Amazon's managed policy for RDS enhanced monitoring
resource "aws_iam_role_policy_attachment" "enhanced_monitoring" {
role = "${aws_iam_role.enhanced_monitoring.name}"
role = aws_iam_role.enhanced_monitoring.name
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole"
}
Expand Down Expand Up @@ -220,10 +220,10 @@ module "rds_cluster_aurora_postgres" {
zone_id = "Zxxxxxxxx"
# enable monitoring every 30 seconds
rds_monitoring_interval = "30"
rds_monitoring_interval = 30
# reference iam role created above
rds_monitoring_role_arn = "${aws_iam_role.enhanced_monitoring.arn}"
rds_monitoring_role_arn = aws_iam_role.enhanced_monitoring.arn
}
```

Expand All @@ -248,55 +248,55 @@ Available targets:
|------|-------------|:----:|:-----:|:-----:|
| admin_password | (Required unless a snapshot_identifier is provided) Password for the master DB user | string | `` | no |
| admin_user | (Required unless a snapshot_identifier is provided) Username for the master DB user | string | `admin` | no |
| allowed_cidr_blocks | List of CIDR blocks allowed to access | list | `<list>` | no |
| apply_immediately | Specifies whether any cluster modifications are applied immediately, or during the next maintenance window | string | `true` | no |
| attributes | Additional attributes (e.g. `1`) | list | `<list>` | no |
| autoscaling_enabled | Whether to enable cluster autoscaling | string | `false` | no |
| autoscaling_max_capacity | Maximum number of instances to be maintained by the autoscaler | string | `5` | no |
| autoscaling_min_capacity | Minimum number of instances to be maintained by the autoscaler | string | `1` | no |
| allowed_cidr_blocks | List of CIDR blocks allowed to access the cluster | list(string) | `<list>` | no |
| apply_immediately | Specifies whether any cluster modifications are applied immediately, or during the next maintenance window | bool | `true` | no |
| attributes | Additional attributes (e.g. `1`) | list(string) | `<list>` | no |
| autoscaling_enabled | Whether to enable cluster autoscaling | bool | `false` | no |
| autoscaling_max_capacity | Maximum number of instances to be maintained by the autoscaler | number | `5` | no |
| autoscaling_min_capacity | Minimum number of instances to be maintained by the autoscaler | number | `1` | no |
| autoscaling_policy_type | Autoscaling policy type. `TargetTrackingScaling` and `StepScaling` are supported | string | `TargetTrackingScaling` | no |
| autoscaling_scale_in_cooldown | The amount of time, in seconds, after a scaling activity completes and before the next scaling down activity can start. Default is 300s | string | `300` | no |
| autoscaling_scale_out_cooldown | The amount of time, in seconds, after a scaling activity completes and before the next scaling up activity can start. Default is 300s | string | `300` | no |
| autoscaling_scale_in_cooldown | The amount of time, in seconds, after a scaling activity completes and before the next scaling down activity can start. Default is 300s | number | `300` | no |
| autoscaling_scale_out_cooldown | The amount of time, in seconds, after a scaling activity completes and before the next scaling up activity can start. Default is 300s | number | `300` | no |
| autoscaling_target_metrics | The metrics type to use. If this value isn't provided the default is CPU utilization | string | `RDSReaderAverageCPUUtilization` | no |
| autoscaling_target_value | The target value to scale with respect to target metrics | string | `75` | no |
| autoscaling_target_value | The target value to scale with respect to target metrics | number | `75` | no |
| backup_window | Daily time range during which the backups happen | string | `07:00-09:00` | no |
| cluster_dns_name | Name of the cluster CNAME record to create in the parent DNS zone specified by `zone_id`. If left empty, the name will be auto-asigned using the format `master.var.name` | string | `` | no |
| cluster_family | The family of the DB cluster parameter group | string | `aurora5.6` | no |
| cluster_parameters | List of DB parameters to apply | list | `<list>` | no |
| cluster_size | Number of DB instances to create in the cluster | string | `2` | no |
| cluster_parameters | List of DB cluster parameters to apply | object | `<list>` | no |
| cluster_size | Number of DB instances to create in the cluster | number | `2` | no |
| db_name | Database name | string | - | yes |
| db_port | Database port | string | `3306` | no |
| deletion_protection | If the DB instance should have deletion protection enabled. | string | `false` | no |
| db_port | Database port | number | `3306` | no |
| deletion_protection | If the DB instance should have deletion protection enabled | bool | `false` | no |
| delimiter | Delimiter to be used between `name`, `namespace`, `stage` and `attributes` | string | `-` | no |
| enabled | Set to false to prevent the module from creating any resources | string | `true` | no |
| enabled_cloudwatch_logs_exports | List of log types to export to cloudwatch. The following log types are supported: audit, error, general, slowquery. | list | `<list>` | no |
| enabled | Set to false to prevent the module from creating any resources | bool | `true` | no |
| enabled_cloudwatch_logs_exports | List of log types to export to cloudwatch. The following log types are supported: audit, error, general, slowquery | list(string) | `<list>` | no |
| engine | The name of the database engine to be used for this DB cluster. Valid values: `aurora`, `aurora-mysql`, `aurora-postgresql` | string | `aurora` | no |
| engine_mode | The database engine mode. Valid values: `parallelquery`, `provisioned`, `serverless` | string | `provisioned` | no |
| engine_version | The version number of the database engine to use | string | `` | no |
| iam_database_authentication_enabled | Specifies whether or mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled. | string | `false` | no |
| iam_database_authentication_enabled | Specifies whether or mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled | bool | `false` | no |
| instance_availability_zone | Optional parameter to place cluster instances in a specific availability zone. If left empty, will place randomly | string | `` | no |
| instance_parameters | List of DB instance parameters to apply | list | `<list>` | no |
| instance_parameters | List of DB instance parameters to apply | object | `<list>` | no |
| instance_type | Instance type to use | string | `db.t2.small` | no |
| kms_key_arn | The ARN for the KMS encryption key. When specifying kms_key_arn, storage_encrypted needs to be set to true. | string | `` | no |
| kms_key_arn | The ARN for the KMS encryption key. When specifying `kms_key_arn`, `storage_encrypted` needs to be set to `true` | string | `` | no |
| maintenance_window | Weekly time range during which system maintenance can occur, in UTC | string | `wed:03:00-wed:04:00` | no |
| name | Name of the application | string | - | yes |
| namespace | Namespace (e.g. `eg` or `cp`) | string | - | yes |
| performance_insights_enabled | Whether to enable Performance Insights | string | `false` | no |
| namespace | Namespace (e.g. `eg` or `cp`) | string | `` | no |
| performance_insights_enabled | Whether to enable Performance Insights | bool | `false` | no |
| performance_insights_kms_key_id | The ARN for the KMS key to encrypt Performance Insights data. When specifying `performance_insights_kms_key_id`, `performance_insights_enabled` needs to be set to true | string | `` | no |
| publicly_accessible | Set to true if you want your cluster to be publicly accessible (such as via QuickSight) | string | `false` | no |
| rds_monitoring_interval | Interval in seconds that metrics are collected, 0 to disable (values can only be 0, 1, 5, 10, 15, 30, 60) | string | `0` | no |
| publicly_accessible | Set to true if you want your cluster to be publicly accessible (such as via QuickSight) | bool | `false` | no |
| rds_monitoring_interval | Interval in seconds that metrics are collected, 0 to disable (values can only be 0, 1, 5, 10, 15, 30, 60) | number | `0` | no |
| rds_monitoring_role_arn | The ARN for the IAM role that can send monitoring metrics to CloudWatch Logs | string | `` | no |
| reader_dns_name | Name of the reader endpoint CNAME record to create in the parent DNS zone specified by `zone_id`. If left empty, the name will be auto-asigned using the format `replicas.var.name` | string | `` | no |
| replication_source_identifier | ARN of a source DB cluster or DB instance if this DB cluster is to be created as a Read Replica | string | `` | no |
| retention_period | Number of days to retain backups for | string | `5` | no |
| scaling_configuration | List of nested attributes with scaling properties. Only valid when engine_mode is set to `serverless` | list | `<list>` | no |
| security_groups | List of security groups to be allowed to connect to the DB instance | list | `<list>` | no |
| skip_final_snapshot | Determines whether a final DB snapshot is created before the DB cluster is deleted | string | `true` | no |
| retention_period | Number of days to retain backups for | number | `5` | no |
| scaling_configuration | List of nested attributes with scaling properties. Only valid when `engine_mode` is set to `serverless` | object | `<list>` | no |
| security_groups | List of security groups to be allowed to connect to the DB instance | list(string) | `<list>` | no |
| skip_final_snapshot | Determines whether a final DB snapshot is created before the DB cluster is deleted | bool | `true` | no |
| snapshot_identifier | Specifies whether or not to create this cluster from a snapshot | string | `` | no |
| stage | Stage (e.g. `prod`, `dev`, `staging`) | string | - | yes |
| storage_encrypted | Specifies whether the DB cluster is encrypted. The default is `false` for `provisioned` `engine_mode` and `true` for `serverless` `engine_mode` | string | `false` | no |
| subnets | List of VPC subnet IDs | list | - | yes |
| tags | Additional tags (e.g. map(`BusinessUnit`,`XYZ`) | map | `<map>` | no |
| stage | Stage (e.g. `prod`, `dev`, `staging`) | string | `` | no |
| storage_encrypted | Specifies whether the DB cluster is encrypted. The default is `false` for `provisioned` `engine_mode` and `true` for `serverless` `engine_mode` | bool | `false` | no |
| subnets | List of VPC subnet IDs | list(string) | - | yes |
| tags | Additional tags (e.g. map(`BusinessUnit`,`XYZ`) | map(string) | `<map>` | no |
| vpc_id | VPC ID to create the cluster in (e.g. `vpc-a22222ee`) | string | - | yes |
| zone_id | Route53 parent zone ID. If provided (not empty), the module will create sub-domain DNS records for the DB master and replicas | string | `` | no |

Expand All @@ -305,15 +305,16 @@ Available targets:
| Name | Description |
|------|-------------|
| arn | Amazon Resource Name (ARN) of cluster |
| cluster_name | Cluster Identifier |
| cluster_resource_id | The region-unique, immutable identifie of the cluster. |
| dbi_resource_ids | List of the region-unique, immutable identifiers for the DB instances in the cluster. |
| cluster_identifier | Cluster Identifier |
| cluster_resource_id | The region-unique, immutable identifie of the cluster |
| cluster_security_groups | Default RDS cluster security groups |
| database_name | Database name |
| dbi_resource_ids | List of the region-unique, immutable identifiers for the DB instances in the cluster |
| endpoint | The DNS address of the RDS instance |
| master_host | DB Master hostname |
| name | Database name |
| master_username | Username for the master DB user |
| reader_endpoint | A read-only endpoint for the Aurora cluster, automatically load-balanced across replicas |
| replicas_host | Replicas hostname |
| user | Username for the master DB user |



Expand Down
22 changes: 11 additions & 11 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ github_repo: cloudposse/terraform-aws-rds-cluster

# Badges to display
badges:
- name: "Build Status"
image: "https://travis-ci.org/cloudposse/terraform-aws-rds-cluster.svg?branch=master"
url: "https://travis-ci.org/cloudposse/terraform-aws-rds-cluster"
- name: "Codefresh Build Status"
image: "https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-aws-rds-cluster?type=cf-1"
url: "https://g.codefresh.io/public/accounts/cloudposse/pipelines/5d1eb949a7e22e49dc7ea7c9"
- name: "Latest Release"
image: "https://img.shields.io/github/release/cloudposse/terraform-aws-rds-cluster.svg"
url: "https://github.com/cloudposse/terraform-aws-rds-cluster/releases/latest"
Expand Down Expand Up @@ -113,7 +113,7 @@ usage: |-
max_capacity = 256
min_capacity = 2
seconds_until_auto_pause = 300
},
}
]
}
```
Expand Down Expand Up @@ -161,11 +161,11 @@ usage: |-
},
{
name = "collation_connection"
value = "uft8_bin"
value = "utf8_bin"
},
{
name = "collation_server"
value = "uft8_bin"
value = "utf8_bin"
},
{
name = "lower_case_table_names"
Expand All @@ -176,7 +176,7 @@ usage: |-
name = "skip-character-set-client-handshake"
value = "1"
apply_method = "pending-reboot"
},
}
]
}
```
Expand All @@ -187,12 +187,12 @@ usage: |-
# create IAM role for monitoring
resource "aws_iam_role" "enhanced_monitoring" {
name = "rds-cluster-example-1"
assume_role_policy = "${data.aws_iam_policy_document.enhanced_monitoring.json}"
assume_role_policy = data.aws_iam_policy_document.enhanced_monitoring.json
}
# Attach Amazon's managed policy for RDS enhanced monitoring
resource "aws_iam_role_policy_attachment" "enhanced_monitoring" {
role = "${aws_iam_role.enhanced_monitoring.name}"
role = aws_iam_role.enhanced_monitoring.name
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole"
}
Expand Down Expand Up @@ -231,10 +231,10 @@ usage: |-
zone_id = "Zxxxxxxxx"
# enable monitoring every 30 seconds
rds_monitoring_interval = "30"
rds_monitoring_interval = 30
# reference iam role created above
rds_monitoring_role_arn = "${aws_iam_role.enhanced_monitoring.arn}"
rds_monitoring_role_arn = aws_iam_role.enhanced_monitoring.arn
}
```
Expand Down
74 changes: 74 additions & 0 deletions codefresh/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
version: '1.0'

stages:
- Prepare
- Test

steps:
wait:
title: Wait
stage: Prepare
image: codefresh/cli:latest
commands:
- codefresh get builds --pipeline=${{CF_REPO_NAME}} --status running --limit 1000 -o json | jq --arg id ${{CF_BUILD_ID}} -ser 'flatten|.[-1].id==$id'
retry:
maxAttempts: 10
delay: 20
exponentialFactor: 1.1

main_clone:
title: "Clone repository"
type: git-clone
stage: Prepare
description: "Initialize"
repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}
git: CF-default
revision: ${{CF_REVISION}}

clean_init:
title: Prepare build-harness and test-harness
image: ${{TEST_IMAGE}}
stage: Prepare
commands:
- cf_export PATH="/usr/local/terraform/0.12/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
- make init
- git -C build-harness checkout master
- make -C test/ clean init TEST_HARNESS_BRANCH=master
- make -C test/src clean init
- find . -type d -name '.terraform' | xargs rm -rf
- find . -type f -name 'terraform.tfstate*' -exec rm -f {} \;

test:
type: "parallel"
title: "Run tests"
description: "Run all tests in parallel"
stage: Test
steps:
test_readme_lint:
title: "Test README.md updated"
stage: "Test"
image: ${{TEST_IMAGE}}
description: Test "readme/lint"
commands:
- make readme/lint

test_module:
title: Test module with bats
image: ${{TEST_IMAGE}}
stage: Test
commands:
- make -C test/ module

test_examples_complete:
title: Test "examples/complete" with bats
image: ${{TEST_IMAGE}}
stage: Test
commands:
- make -C test/ examples/complete

test_examples_complete_terratest:
title: Test "examples/complete" with terratest
image: ${{TEST_IMAGE}}
stage: Test
commands:
- make -C test/src
Loading

0 comments on commit 946a7a2

Please sign in to comment.