GeezerVison is showing github.com — sendgrid integration by davidcheung · Pull Request #79 · commitdev/zero-aws-eks-stack
sendgrid integration
#79
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
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension
.md
(1)
.tf
(5)
.yml
(1)
No extension
(1)
All 4 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
README.md
Original file line number
Diff line number
Diff line change
Expand Up
@@ -42,6 +42,9 @@ which describes the environment mapped in this [architecture diagram][arch-diagr
- [A domain registered with Route53][aws-route53]
- Note: if you want to use different domain per environment (staging/production), you need to have multiple hosted zones. The available zones in Route53 can be found by running this command. `aws route53 list-hosted-zones`
_Optional Prerequisites_
- [Sendgrid account][sendgrid] with developer [API key][sendgrid-apikey]: this will enable transactional email sending with simple API calls.
## Getting Started
This is meant to be used with the `zero` tool and not directly. See
Expand Down
Expand Up
@@ -73,3 +76,5 @@ Project board: [zenhub][zenhub-board]
[aws-cli]: https://docs.aws.amazon.com/polly/latest/dg/setup-aws-cli.html
[aws-route53]: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/domain-register.html
[zenhub-board]: https://app.zenhub.com/workspaces/commit-zero-5da8decc7046a60001c6db44/board?filterLogic=any&repos=203630543,247773730,257676371,258369081
[sendgrid]: https://signup.sendgrid.com
[sendgrid-apikey]: https://app.sendgrid.com/settings/api_keys
Original file line number
Diff line number
Diff line change
Expand Up
@@ -47,6 +47,7 @@ teardown-secrets:
export AWS_PAGER='' && export AWS_DEFAULT_REGION=<% index .Params `region` %> && \
aws secretsmanager list-secrets --region <% index .Params `region` %> --query "SecretList[?Tags[?Key=='project' && Value=='$(PROJECT)']].[Name] | [0][0]" | xargs aws secretsmanager delete-secret --region <% index .Params `region` %> --secret-id && \
aws secretsmanager list-secrets --region <% index .Params `region` %> --query "SecretList[?Tags[?Key=='rds' && Value=='$(PROJECT)-$(ENVIRONMENT)']].[Name] | [0][0]" | xargs aws secretsmanager delete-secret --region <% index .Params `region` %> --secret-id && \
aws secretsmanager list-secrets --region <% index .Params `region` %> --query "SecretList[?Tags[?Key=='sendgrid' && Value=='$(PROJECT)']].[Name] | [0][0]" | xargs aws secretsmanager delete-secret --region <% index .Params `region` %> --secret-id && \
aws iam delete-access-key --user-name $(PROJECT)-ci-user --access-key-id $(shell aws iam list-access-keys --user-name $(PROJECT)-ci-user --query "AccessKeyMetadata[0].AccessKeyId" | sed 's/"//g') && \
aws iam delete-user --user-name $(PROJECT)-ci-user
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -47,3 +47,11 @@ module "rds_master_secret_prod" {
random_length = 32
tags = map("rds", "${local.project}-prod")
}
module "sendgrid_api_key" {
source = "../../modules/secret"
name = "${local.project}-sendgrid-<% index .Params `randomSeed` %>"
Comment thread
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 .
This assumes the same api key will be shared for both staging / production, which I think is probably fine for now.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
type = "string"
value = "<% index .Params `sendgridApiKey` %>"
tags = map("sendgrid", local.project)
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -53,4 +53,7 @@ module "prod" {
<% if ne (index .Params `loggingType`) "kibana" %># <% end %>logging_es_instance_count = "2" # Must be a mulitple of the az count
<% if ne (index .Params `loggingType`) "kibana" %># <% end %>logging_volume_size_in_gb = "50" # Maximum value is limited by the instance type
# See https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/aes-limits.html
sendgrid_enabled = <%if eq (index .Params `sendgridApiKey`) "" %>false<% else %>true<% end %>
sendgrid_api_key_secret_name = "<% .Name %>-sendgrid-<% index .Params `randomSeed` %>"
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -58,4 +58,7 @@ module "stage" {
<% if ne (index .Params `loggingType`) "kibana" %># <% end %>logging_es_instance_count = "1" # Must be a mulitple of the az count
<% if ne (index .Params `loggingType`) "kibana" %># <% end %>logging_volume_size_in_gb = "10" # Maximum value is limited by the instance type
# See https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/aes-limits.html
sendgrid_enabled = <%if eq (index .Params `sendgridApiKey`) "" %>false<% else %>true<% end %>
sendgrid_api_key_secret_name = "<% .Name %>-sendgrid-<% index .Params `randomSeed` %>"
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -118,3 +118,12 @@ module "logging" {
ebs_volume_size_in_gb = var.logging_volume_size_in_gb
create_service_role = var.logging_create_service_role
}
module "sendgrid" {
source = "commitdev/zero/aws//modules/sendgrid"
version = "0.0.2"
count = var.sendgrid_enabled ? 1 : 0
zone_name = var.domain_name
sendgrid_api_key_secret_name = var.sendgrid_api_key_secret_name
Comment thread
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 .
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -127,3 +127,13 @@ variable "enable_cluster_logging" {
type = bool
default = false
}
variable "sendgrid_enabled" {
description = "If enabled, creates route53 entries for domain authentication"
type = bool
}
variable "sendgrid_api_key_secret_name" {
description = "AWS secret manager's secret name storing the sendgrid api key"
type = string
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -71,6 +71,9 @@ parameters:
options:
- "cloudwatch"
- "kibana"
- field: sendgridApiKey
label: "API key to setup email integration (optional: leave blank to opt-out of Sendgrid setup)"
info: Signup at https://signup.sendgrid.com or create an API key from https://app.sendgrid.com/settings/api_keys. Sendgrid is an email delivery service enabling transactional email sending and more.
Comment thread
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 .
How about a note here that they can leave this blank to not set up sendgrid?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
- field: accountId
label: AWS Account ID
execute: aws sts get-caller-identity --query "Account" | tr -d '"'
Expand Down
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.