Skip to content

Commit

Permalink
feat!: Add support for feature flag (#8)
Browse files Browse the repository at this point in the history
Co-authored-by: Bryant Biggs <bryantbiggs@gmail.com>
  • Loading branch information
mlnrt and bryantbiggs authored Oct 30, 2023
1 parent 4eefe14 commit 44f1a5d
Show file tree
Hide file tree
Showing 26 changed files with 112 additions and 69 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.77.0
rev: v1.83.5
hooks:
- id: terraform_fmt
- id: terraform_validate
Expand All @@ -23,7 +23,7 @@ repos:
- '--args=--only=terraform_standard_module_structure'
- '--args=--only=terraform_workspace_remote'
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ See [`examples`](https://github.com/terraform-aws-modules/terraform-aws-appconfi
```hcl
module "appconfig" {
source = "terraform-aws-modules/appconfig/aws"
version = "~> 1.0"
name = "example"
description = "AppConfig hosted configuration"
Expand Down Expand Up @@ -78,14 +77,14 @@ Examples codified under the [`examples`](https://github.com/terraform-aws-module

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.55 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.55 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0 |

## Modules

Expand Down Expand Up @@ -118,6 +117,7 @@ No modules.
| <a name="input_config_profile_name"></a> [config\_profile\_name](#input\_config\_profile\_name) | The name for the configuration profile. Must be between 1 and 64 characters in length | `string` | `null` | no |
| <a name="input_config_profile_retrieval_role_arn"></a> [config\_profile\_retrieval\_role\_arn](#input\_config\_profile\_retrieval\_role\_arn) | The ARN of an IAM role with permission to access the configuration at the specified `location_uri`. A retrieval role ARN is not required for configurations stored in the AWS AppConfig `hosted` configuration store. It is required for all other sources that store your configuration | `string` | `null` | no |
| <a name="input_config_profile_tags"></a> [config\_profile\_tags](#input\_config\_profile\_tags) | A map of additional tags to apply to the configuration profile | `map(string)` | `{}` | no |
| <a name="input_config_profile_type"></a> [config\_profile\_type](#input\_config\_profile\_type) | Type of configurations contained in the profile. Valid values: `AWS.AppConfig.FeatureFlags` and `AWS.Freeform` | `string` | `null` | no |
| <a name="input_config_profile_validator"></a> [config\_profile\_validator](#input\_config\_profile\_validator) | A set of methods for validating the configuration. Maximum of 2 | `list(map(any))` | `[]` | no |
| <a name="input_create"></a> [create](#input\_create) | Determines whether resources are created | `bool` | `true` | no |
| <a name="input_create_deployment_strategy"></a> [create\_deployment\_strategy](#input\_create\_deployment\_strategy) | Determines whether a deployment strategy is created | `bool` | `true` | no |
Expand Down
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Terraform AWS AppConfig examples

- [AppConfig Hosted](https://github.com/terraform-aws-modules/terraform-aws-appconfig/tree/master/examples/appconfig_hosted)
- [Feature Flag](https://github.com/terraform-aws-modules/terraform-aws-appconfig/tree/master/examples/feature_flag)
- [S3](https://github.com/terraform-aws-modules/terraform-aws-appconfig/tree/master/examples/s3)
- [SSM Document](https://github.com/terraform-aws-modules/terraform-aws-appconfig/tree/master/examples/ssm_document)
- [SSM Parameter](https://github.com/terraform-aws-modules/terraform-aws-appconfig/tree/master/examples/ssm_parameter)
13 changes: 13 additions & 0 deletions examples/_configs/feature_flags.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"flags": {
"is_enabled": {
"name": "isEnabled"
}
},
"values": {
"is_enabled": {
"enabled": "false"
}
},
"version": "1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ Note that this example may create resources which will incur monetary charges on

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_archive"></a> [archive](#requirement\_archive) | >= 2.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.55 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0 |

## Providers

Expand All @@ -40,8 +40,9 @@ Note that this example may create resources which will incur monetary charges on
| Name | Source | Version |
|------|--------|---------|
| <a name="module_appconfig"></a> [appconfig](#module\_appconfig) | ../../ | n/a |
| <a name="module_appconfig_feature_flag"></a> [appconfig\_feature\_flag](#module\_appconfig\_feature\_flag) | ../../ | n/a |
| <a name="module_deactivated_appconfig"></a> [deactivated\_appconfig](#module\_deactivated\_appconfig) | ../../ | n/a |
| <a name="module_validate_lambda"></a> [validate\_lambda](#module\_validate\_lambda) | terraform-aws-modules/lambda/aws | ~> 2.0 |
| <a name="module_validate_lambda"></a> [validate\_lambda](#module\_validate\_lambda) | terraform-aws-modules/lambda/aws | ~> 6.0 |

## Resources

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ provider "aws" {

locals {
region = "us-east-1"
name = "appconfig-ex-${replace(basename(path.cwd), "_", "-")}"
name = "ex-${basename(path.cwd)}"

tags = {
Name = local.name
Expand Down Expand Up @@ -59,6 +59,33 @@ module "appconfig" {
tags = local.tags
}

module "appconfig_feature_flag" {
source = "../../"

name = "${local.name}-feature-flag"
description = "AppConfig hosted feature flag - ${local.name}"

# environments
environments = {
nonprod = {
name = "nonprod"
description = "NonProd environment - ${local.name}"
},
prod = {
name = "prod"
description = "Prod environment - ${local.name}"
}
}

# hosted config version
use_hosted_configuration = true
config_profile_type = "AWS.AppConfig.FeatureFlags"
hosted_config_version_content_type = "application/json"
hosted_config_version_content = file("../_configs/feature_flags.json")

tags = local.tags
}

################################################################################
# Supporting Resources
################################################################################
Expand All @@ -71,7 +98,7 @@ data "archive_file" "lambda_handler" {

module "validate_lambda" {
source = "terraform-aws-modules/lambda/aws"
version = "~> 2.0"
version = "~> 6.0"

function_name = local.name
description = "Configuration semantic validation lambda"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
terraform {
required_version = ">= 0.13.1"
required_version = ">= 1.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.55"
version = ">= 5.0"
}
archive = {
source = "hashicorp/archive"
Expand Down
12 changes: 6 additions & 6 deletions examples/s3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,30 @@ Note that this example may create resources which will incur monetary charges on

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_archive"></a> [archive](#requirement\_archive) | >= 2.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.55 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_archive"></a> [archive](#provider\_archive) | >= 2.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.55 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_appconfig"></a> [appconfig](#module\_appconfig) | ../../ | n/a |
| <a name="module_s3_bucket"></a> [s3\_bucket](#module\_s3\_bucket) | terraform-aws-modules/s3-bucket/aws | ~> 2.0 |
| <a name="module_validate_lambda"></a> [validate\_lambda](#module\_validate\_lambda) | terraform-aws-modules/lambda/aws | ~> 2.0 |
| <a name="module_s3_bucket"></a> [s3\_bucket](#module\_s3\_bucket) | terraform-aws-modules/s3-bucket/aws | ~> 3.0 |
| <a name="module_validate_lambda"></a> [validate\_lambda](#module\_validate\_lambda) | terraform-aws-modules/lambda/aws | ~> 6.0 |

## Resources

| Name | Type |
|------|------|
| [aws_s3_bucket_object.config](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object) | resource |
| [aws_s3_object.config](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_object) | resource |
| [archive_file.lambda_handler](https://registry.terraform.io/providers/hashicorp/archive/latest/docs/data-sources/file) | data source |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
Expand Down
18 changes: 6 additions & 12 deletions examples/s3/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ provider "aws" {

locals {
region = "us-east-1"
name = "appconfig-ex-${replace(basename(path.cwd), "_", "-")}"
name = "ex-${basename(path.cwd)}"

tags = {
Name = local.name
Expand All @@ -14,7 +14,6 @@ locals {
}

data "aws_region" "current" {}

data "aws_caller_identity" "current" {}

################################################################################
Expand Down Expand Up @@ -43,7 +42,7 @@ module "appconfig" {
use_s3_configuration = true
s3_configuration_bucket_arn = module.s3_bucket.s3_bucket_arn
retrieval_role_description = "Role to retrieve configuration stored in S3"
config_profile_location_uri = "s3://${module.s3_bucket.s3_bucket_id}/${aws_s3_bucket_object.config.id}"
config_profile_location_uri = "s3://${module.s3_bucket.s3_bucket_id}/${aws_s3_object.config.id}"
config_profile_validator = [{
type = "JSON_SCHEMA"
content = file("../_configs/config_validator.json")
Expand All @@ -53,7 +52,7 @@ module "appconfig" {
}]

# deployment
deployment_configuration_version = aws_s3_bucket_object.config.version_id
deployment_configuration_version = aws_s3_object.config.version_id

tags = local.tags
}
Expand All @@ -70,7 +69,7 @@ data "archive_file" "lambda_handler" {

module "validate_lambda" {
source = "terraform-aws-modules/lambda/aws"
version = "~> 2.0"
version = "~> 6.0"

function_name = local.name
description = "Configuration semantic validation lambda"
Expand Down Expand Up @@ -98,7 +97,7 @@ module "validate_lambda" {

module "s3_bucket" {
source = "terraform-aws-modules/s3-bucket/aws"
version = "~> 2.0"
version = "~> 3.0"

bucket = "${local.name}-${data.aws_caller_identity.current.account_id}-${data.aws_region.current.name}"
acl = "private"
Expand All @@ -108,11 +107,6 @@ module "s3_bucket" {
# Intended for example use only
force_destroy = true

block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true

server_side_encryption_configuration = {
rule = {
apply_server_side_encryption_by_default = {
Expand All @@ -128,7 +122,7 @@ module "s3_bucket" {
tags = local.tags
}

resource "aws_s3_bucket_object" "config" {
resource "aws_s3_object" "config" {
bucket = module.s3_bucket.s3_bucket_id
key = "s3/config.json"
source = "../_configs/config.json"
Expand Down
4 changes: 2 additions & 2 deletions examples/s3/versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
terraform {
required_version = ">= 0.13.1"
required_version = ">= 1.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.55"
version = ">= 5.0"
}
archive = {
source = "hashicorp/archive"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ Note that this example may create resources which will incur monetary charges on

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.55 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.55 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0 |

## Modules

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ provider "aws" {

locals {
region = "us-east-1"
name = "appconfig-ex-${replace(basename(path.cwd), "_", "-")}"
name = "ex-${basename(path.cwd)}"

tags = {
Name = local.name
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
terraform {
required_version = ">= 0.13.1"
required_version = ">= 1.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.55"
version = ">= 5.0"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ Note that this example may create resources which will incur monetary charges on

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_archive"></a> [archive](#requirement\_archive) | >= 2.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.55 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_archive"></a> [archive](#provider\_archive) | >= 2.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.55 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_appconfig"></a> [appconfig](#module\_appconfig) | ../../ | n/a |
| <a name="module_validate_lambda"></a> [validate\_lambda](#module\_validate\_lambda) | terraform-aws-modules/lambda/aws | ~> 2.0 |
| <a name="module_validate_lambda"></a> [validate\_lambda](#module\_validate\_lambda) | terraform-aws-modules/lambda/aws | ~> 6.0 |

## Resources

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ provider "aws" {

locals {
region = "us-east-1"
name = "appconfig-ex-${replace(basename(path.cwd), "_", "-")}"
name = "ex-${basename(path.cwd)}"

tags = {
Name = local.name
Expand Down Expand Up @@ -68,7 +68,7 @@ data "archive_file" "lambda_handler" {

module "validate_lambda" {
source = "terraform-aws-modules/lambda/aws"
version = "~> 2.0"
version = "~> 6.0"

function_name = local.name
description = "Configuration semantic validation lambda"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
terraform {
required_version = ">= 0.13.1"
required_version = ">= 1.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.55"
version = ">= 5.0"
}
archive = {
source = "hashicorp/archive"
Expand Down
Loading

0 comments on commit 44f1a5d

Please sign in to comment.