-
Notifications
You must be signed in to change notification settings - Fork 61
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
Added support for docdb #60
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Added support for docdb
So in order for docdb to have tls encryption during transit, the guides https://docs.aws.amazon.com/documentdb/latest/developerguide/security.encryption.ssl.html https://docs.aws.amazon.com/documentdb/latest/developerguide/connect_programmatically.html Call for the public keys to be downloaded/present in each container using it. The size of the file (~5kb) is just shy of 5% the capacity of a single k8s configmap value so what's happening is each deployment now has a configmap resource which for now only has 1 key (the rds ca pem) which is put in the /config/rds_ca.pem path (and there's now an envar pointing directly to that). With that in place a user can now have their app use docdb by referencing 4 environment variables: username, password, hostname, and ca_path. WE NEED TO BE SURE TO TELL FOLKS IN OUR DOCDB MODULE DOCS TO USE THAT ENVAR.
- Loading branch information
commit 0d3bcdf6d529e2e85f7cd1f84fc44eff0d77983f
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
resource "random_password" "documentdb_auth" { | ||
length = 20 | ||
special = false | ||
} | ||
|
||
data "aws_security_group" "security_group" { | ||
count = var.security_group == "" ? 1 : 0 | ||
name = "documentdb-sg" | ||
} | ||
|
||
resource "aws_docdb_cluster_instance" "cluster_instances" { | ||
count = 1 | ||
identifier = "${var.name}-${count.index}" | ||
cluster_identifier = aws_docdb_cluster.cluster.id | ||
instance_class = var.instance_class | ||
apply_immediately = true | ||
auto_minor_version_upgrade = true | ||
} | ||
|
||
resource "aws_docdb_cluster" "cluster" { | ||
cluster_identifier = var.name | ||
master_username = "master_user" | ||
master_password = random_password.documentdb_auth.result | ||
db_subnet_group_name = var.subnet_group_name | ||
engine_version = var.engine_version | ||
storage_encrypted = true | ||
kms_key_id = var.kms_account_key_arn | ||
vpc_security_group_ids = var.security_group == "" ? [data.aws_security_group.security_group[0].id] : [var.security_group] | ||
apply_immediately = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
output "db_host" { | ||
value = aws_docdb_cluster.cluster.endpoint | ||
} | ||
|
||
output "db_user" { | ||
value = aws_docdb_cluster.cluster.master_username | ||
} | ||
|
||
output "db_password" { | ||
value = aws_docdb_cluster.cluster.master_password | ||
sensitive = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
variable "name" { | ||
type = string | ||
} | ||
|
||
variable "subnet_group_name" { | ||
type = string | ||
default = "main-docdb" | ||
} | ||
|
||
variable "engine_version" { | ||
type = string | ||
default = "4.0.0" | ||
} | ||
|
||
variable "security_group" { | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "instance_class" { | ||
type = string | ||
default = "db.r5.large" | ||
} | ||
|
||
variable "kms_account_key_arn" { | ||
type = string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
resource "aws_db_subnet_group" "main" { | ||
name = "main" | ||
subnet_ids = aws_subnet.private_subnets[*].id | ||
tags = { | ||
"purpose": "postgres" | ||
"ignore-if-seemingly-out-of-place": "yup" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
resource "aws_docdb_subnet_group" "main" { | ||
name = "main-docdb" | ||
subnet_ids = aws_subnet.private_subnets[*].id | ||
tags = { | ||
"purpose": "docdb" | ||
"ignore-if-seemingly-out-of-place": "yup" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
729 changes: 729 additions & 0 deletions
729
config/tf_modules/k8s-service/k8s-service/templates/configmap.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,10 @@ spec: | |
- name: {{ .Chart.Name }} | ||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" | ||
imagePullPolicy: Always | ||
volumeMounts: | ||
- name: config | ||
mountPath: "/config" | ||
readOnly: true | ||
ports: | ||
- name: http | ||
containerPort: {{ .Values.port }} | ||
|
@@ -37,8 +41,10 @@ spec: | |
httpGet: | ||
path: {{ .Values.livenessProbePath }} | ||
port: http | ||
{{- if or (.Values.envVars) (.Values.secrets) }} | ||
env: | ||
- name: RDS_CA_PATH | ||
value: "/config/rds_ca.pem" | ||
{{- if or (.Values.envVars) (.Values.secrets) }} | ||
{{ range .Values.envVars }} | ||
- name: {{ .name | quote }} | ||
value: {{ .value | quote }} | ||
|
@@ -50,7 +56,7 @@ spec: | |
name: secret | ||
key: {{ $val | quote }} | ||
{{ end }} | ||
{{- end }} | ||
{{- end }} | ||
readinessProbe: | ||
initialDelaySeconds: 10 | ||
periodSeconds: 10 | ||
|
@@ -62,4 +68,14 @@ spec: | |
{{- toYaml .Values.podResourceLimits | nindent 14 }} | ||
requests: | ||
{{- toYaml .Values.podResourceRequests | nindent 14 }} | ||
volumes: | ||
# You set volumes at the Pod level, then mount them into containers inside that Pod | ||
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. nit: the comments in this section don't seem too useful 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. copy pasting lol |
||
- name: config | ||
configMap: | ||
# Provide the name of the ConfigMap you want to mount. | ||
name: {{ include "k8s-service.fullname" . }} | ||
# An array of keys from the ConfigMap to create as files | ||
items: | ||
- key: "rds_ca.pem" | ||
path: "rds_ca.pem" | ||
{{- end }} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment here explaining what this env var represents