-
Notifications
You must be signed in to change notification settings - Fork 5
Add SSM-based feature flags #873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
96e5da0
653b6ac
2945eac
b7e708f
b71bdc7
bd20353
0078a4c
ce76f9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| resource "aws_ssm_parameter" "feature_flags" { | ||
| # checkov:skip=CKV2_AWS_34:Feature flags values don't need to be encrypted | ||
| for_each = var.feature_flags | ||
|
|
||
| name = "/service/${var.service_name}/${each.key}" | ||
| value = each.value | ||
| type = "String" | ||
| description = "Feature flag for ${each.key} in ${var.service_name}" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| output "ssm_parameter_arns" { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not blocking, but given this is tied to SSM/returns ARNs, I wonder if we should name the module like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. It'd be nice to have module names be independent of cloud service provider, so we can have AWS and Azure modules be the same. Interesting idea, I'll leave it as is for now and we can think about ti more. |
||
| description = "Map of feature flag keys to their ARNs" | ||
| value = { for key, param in aws_ssm_parameter.feature_flags : key => param.arn } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| variable "feature_flags" { | ||
| type = map(string) | ||
| description = "A map of feature flags" | ||
| } | ||
|
|
||
| variable "service_name" { | ||
| type = string | ||
| description = "The name of the service that the feature flagging system will be associated with" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| locals { | ||
| feature_flag_defaults = { | ||
| FOO = false | ||
| BAR = false | ||
lorenyu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| feature_flags_config = merge( | ||
| local.feature_flag_defaults, | ||
| var.feature_flag_overrides | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| locals { | ||
| feature_flags_config = local.environment_config.feature_flags_config | ||
|
|
||
| feature_flags_secrets = [ | ||
| for feature_flag in keys(local.feature_flags_config) : { | ||
| name = "FF_${feature_flag}" | ||
| valueFrom = module.feature_flags.ssm_parameter_arns[feature_flag] | ||
| } | ||
| ] | ||
| } | ||
|
|
||
| module "feature_flags" { | ||
| source = "../../modules/feature_flags" | ||
| service_name = local.service_name | ||
| feature_flags = local.feature_flags_config | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import logging | ||
| import os | ||
| import boto3 | ||
| logger = logging.getLogger() | ||
| def is_feature_enabled(feature_name: str) -> bool: | ||
| value = os.environ.get(f"FF_{feature_name}") | ||
| return value == "true" if value else False | ||
|
|
||
lorenyu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Uh oh!
There was an error while loading. Please reload this page.