-
Notifications
You must be signed in to change notification settings - Fork 1
add missing examples, add smtp-user module #26
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
base: main
Are you sure you want to change the base?
Changes from all commits
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,40 @@ | ||
| <!-- BEGIN_TF_DOCS --> | ||
| ## Requirements | ||
|
|
||
| | Name | Version | | ||
| |------|---------| | ||
| | <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) | ~> 5.0 | | ||
|
|
||
| ## Resources | ||
|
|
||
| | Name | Type | | ||
| |------|------| | ||
| | [aws_iam_access_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key) | resource | | ||
| | [aws_iam_policy.ses_sender](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource | | ||
| | [aws_iam_user.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user) | resource | | ||
| | [aws_iam_user_policy_attachment.ses_sender](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment) | resource | | ||
| | [aws_iam_policy_document.ses_sender](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | | ||
|
|
||
| ## Inputs | ||
|
|
||
| | Name | Description | Type | Default | Required | | ||
| |------|-------------|------|---------|:--------:| | ||
| | <a name="input_name"></a> [name](#input\_name) | User name | `string` | n/a | yes | | ||
|
|
||
| ## Outputs | ||
|
|
||
| | Name | Description | | ||
| |------|-------------| | ||
| | <a name="output_access_key_as_envs"></a> [access\_key\_as\_envs](#output\_access\_key\_as\_envs) | User access key map containing AWS\_ACCESS\_KEY\_ID and AWS\_SECRET\_ACCESS\_KEY. | | ||
| | <a name="output_arn"></a> [arn](#output\_arn) | User ARN. | | ||
| | <a name="output_key_id"></a> [key\_id](#output\_key\_id) | Access key ID. | | ||
| | <a name="output_key_secret"></a> [key\_secret](#output\_key\_secret) | Access secret access key. | | ||
| | <a name="output_name"></a> [name](#output\_name) | User name. | | ||
| <!-- END_TF_DOCS --> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| resource "aws_iam_user" "this" { | ||
| name = var.name | ||
| } | ||
|
|
||
| resource "aws_iam_access_key" "this" { | ||
| user = aws_iam_user.this.name | ||
| } | ||
|
|
||
| data "aws_iam_policy_document" "ses_sender" { | ||
| statement { | ||
| actions = ["ses:SendRawEmail"] | ||
| resources = ["*"] | ||
| } | ||
| } | ||
|
|
||
| resource "aws_iam_policy" "ses_sender" { | ||
| name = "ses_sender" | ||
| description = "Allows sending of e-mails via Simple Email Service" | ||
| policy = data.aws_iam_policy_document.ses_sender.json | ||
| } | ||
|
|
||
| resource "aws_iam_user_policy_attachment" "ses_sender" { | ||
| user = aws_iam_user.this.name | ||
| policy_arn = aws_iam_policy.ses_sender.arn | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| output "name" { | ||
| description = "User name." | ||
| value = aws_iam_user.this.name | ||
| } | ||
|
|
||
| output "arn" { | ||
| description = "User ARN." | ||
| value = aws_iam_user.this.arn | ||
| } | ||
|
|
||
| output "access_key_as_envs" { | ||
| description = "User access key map containing AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY." | ||
| value = { | ||
| AWS_ACCESS_KEY_ID = aws_iam_access_key.this.id | ||
| AWS_SECRET_ACCESS_KEY = aws_iam_access_key.this.ses_smtp_password_v4 | ||
| } | ||
| sensitive = true | ||
| } | ||
|
|
||
| output "key_id" { | ||
| description = "Access key ID." | ||
| value = aws_iam_access_key.this.id | ||
| sensitive = true | ||
| } | ||
|
|
||
| output "key_secret" { | ||
| description = "Access secret access key." | ||
| value = aws_iam_access_key.this.ses_smtp_password_v4 | ||
| sensitive = true | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| variable "name" { | ||
| type = string | ||
| description = "User name" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| terraform { | ||
| required_version = "~> 1.0" | ||
|
|
||
| required_providers { | ||
| aws = { | ||
| source = "hashicorp/aws" | ||
| version = "~> 5.0" | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| data "aws_route53_zone" "name" { # TODO adjust name to your project | ||
|
Member
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. in this case i think it is fine to call it "main" |
||
| provider = aws.global | ||
| name = "example.com" # TODO adjust name to your project | ||
| } | ||
|
|
||
| module "cert" { | ||
| providers = { | ||
| aws = aws.global | ||
| } | ||
|
|
||
| source = "../../modules/acm-wildcard" | ||
|
|
||
| domain = "example.com" # TODO adjust name to your project | ||
| validation_zone = "example.com" # TODO adjust name to your project | ||
| wildcard = true | ||
| validate = true | ||
|
|
||
| context = { | ||
| namespace = "name" # TODO adjust name to your project | ||
| stage = "production" | ||
| name = "acm" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,5 +10,4 @@ module "ecr" { | |
|
|
||
| output "url" { | ||
| value = module.ecr.url | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| module "iam_app" { | ||
| source = "../../modules/iam/user-with-access-key" | ||
|
|
||
| name = "name-production" # TODO adjust name to your project | ||
| } | ||
|
|
||
| resource "aws_iam_user_policy_attachment" "allow_sending_email" { | ||
| user = module.iam_app.name # TODO adjust name to your project | ||
| policy_arn = module.ses.send_email_policy_arn | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,5 +23,4 @@ module "db" { | |
| parameter_group_family = "postgres16" | ||
| engine_version = "16.1" | ||
| instance_class = "db.t4g.small" | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,19 @@ | ||
| data "aws_route53_zone" "domain" { | ||
| name = "your-domain.com" # TODO adjust name to your project | ||
| } | ||
|
|
||
| module "cloudfront_dns" { | ||
| source = "../../modules/route53/cloudfront-record" | ||
|
|
||
| name = "" | ||
| zone_id = data.aws_route53_zone.example_com.zone_id # TODO adjust name to your project | ||
| distribution_id = module.cloudfront_app.id | ||
| } | ||
|
|
||
| module "service" { | ||
| source = "../../modules/route53/load-balancer-record" | ||
|
|
||
| lb_arn = module.lb.id | ||
| name = "service" | ||
| zone_id = data.aws_route53_zone.example_com.zone_id # TODO adjust name to your project | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| resource "random_id" "example" { | ||
|
Member
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. change "example" to sth valid |
||
| byte_length = 4 | ||
| prefix = "web-" | ||
| } | ||
|
|
||
| resource "aws_s3_bucket" "this" { | ||
| bucket = "apps-${random_id.example.hex}" | ||
| } | ||
|
|
||
| resource "aws_s3_bucket_public_access_block" "this" { | ||
| bucket = aws_s3_bucket.this.id | ||
|
|
||
| block_public_acls = true | ||
| block_public_policy = true | ||
| ignore_public_acls = true | ||
| restrict_public_buckets = true | ||
| } | ||
|
|
||
| resource "aws_s3_bucket" "app_storage" { | ||
| bucket = "production-name-app-storage" # TODO adjust name to your project | ||
| } | ||
|
|
||
| module "app_storage_s3_read_write" { | ||
| source = "../../modules/iam/s3-read-write" | ||
|
|
||
| name_prefix = "name-storage" # TODO adjust name to your project | ||
| bucket_arn = aws_s3_bucket.app_storage.arn | ||
| users = [module.iam_app.name] # TODO adjust name to your project | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| module "secrets" { | ||
| source = "../../modules/ssm/parameters" | ||
|
|
||
| context = { | ||
| namespace = "name" # TODO adjust name to your project | ||
| stage = "production" | ||
| name = "service" # TODO adjust name to your project | ||
| } | ||
|
|
||
| secrets = { | ||
| NODE_ENV = "production" | ||
| DATABASE_URL = module.db.url | ||
| AWS_REGION = var.region | ||
| } | ||
|
|
||
| editable_secrets = { | ||
| CORS_ORIGIN = "Edit in AWS Console" | ||
| ENVIRONMENT = "Edit in AWS Console" | ||
| } | ||
|
Comment on lines
+16
to
+19
Member
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. remove editables everywhere, let people mange via UI only |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| module "ses" { | ||
| source = "../../modules/ses" | ||
|
|
||
| name_prefix = "name-production" # TODO adjust name to your project | ||
| domain_name = "example.com" | ||
| zone_id = data.aws_route53_zone.example_com.id # TODO adjust name to your project | ||
| verify_dkim = true | ||
| dmarc_enabled = true | ||
| spf_enabled = true | ||
| email_addresses = [ | ||
|
Member
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. production ses, should not have emails as a whitelist anyumore (staging should) |
||
| "your.name@example.com" # TODO adjust name to your project | ||
| ] | ||
| } | ||
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.
you also need ses:SendEmail