GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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.

Sign up for GitHub

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

Merged
davidcheung merged 3 commits into main from sendgrid
Sep 4, 2020

Uh oh!

There was an error while loading. Please reload this page.

Merged

sendgrid integration #79

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
3 commits
Select commit Hold shift + click to select a range
1dac36b
sendgrid integration
davidcheung Sep 1, 2020
fc37a51
reimpl with external datasource
davidcheung Sep 4, 2020
c40187a
docs: message for optional sendgird api key
davidcheung Sep 4, 2020
File filter
Filter by extension

Clear filters
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
Diff view

There are no files selected for viewing

5 changes: 5 additions & 0 deletions 5 README.md
Show comments
View file
Open in desktop
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
1 change: 1 addition & 0 deletions 1 templates/Makefile
Show comments
View file
Open in desktop
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
8 changes: 8 additions & 0 deletions 8 templates/terraform/bootstrap/secrets/main.tf
Show comments
View file
Open in desktop
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

@bmonkman bmonkman Sep 4, 2020

Copy link
Copy Markdown
Contributor

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.

All reactions
type = "string"
value = "<% index .Params `sendgridApiKey` %>"
tags = map("sendgrid", local.project)
}
3 changes: 3 additions & 0 deletions 3 templates/terraform/environments/prod/main.tf
Show comments
View file
Open in desktop
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` %>"
}
3 changes: 3 additions & 0 deletions 3 templates/terraform/environments/stage/main.tf
Show comments
View file
Open in desktop
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` %>"
}
9 changes: 9 additions & 0 deletions 9 templates/terraform/modules/environment/main.tf
Show comments
View file
Open in desktop
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

@davidcheung davidcheung Sep 4, 2020

Copy link
Copy Markdown
Contributor Author

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.

almost all the logic has been moved to commitdev/terraform-aws-zero@bd194a0 with the external-datasource 🎉

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
}
10 changes: 10 additions & 0 deletions 10 templates/terraform/modules/environment/variables.tf
Show comments
View file
Open in desktop
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
}
3 changes: 3 additions & 0 deletions 3 zero-module.yml
Show comments
View file
Open in desktop
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

@bmonkman bmonkman Sep 4, 2020

Copy link
Copy Markdown
Contributor

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.

All reactions
- 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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.