@aws/nx-plugin 1.0.0-rc.76 → 1.0.0-rc.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/migrations.json +16 -1
- package/package.json +1 -1
- package/src/migrations/latest/dynamodb-configurable-encryption/__snapshots__/migration.spec.ts.snap +429 -0
- package/src/migrations/latest/dynamodb-configurable-encryption/metadata.json +3 -0
- package/src/migrations/latest/dynamodb-configurable-encryption/migration.d.ts +6 -0
- package/src/migrations/latest/dynamodb-configurable-encryption/migration.js +325 -0
- package/src/migrations/latest/dynamodb-configurable-encryption/migration.js.map +1 -0
- package/src/migrations/latest/static-website-configurable-waf-encryption/metadata.json +3 -0
- package/src/migrations/latest/static-website-configurable-waf-encryption/migration.d.ts +6 -0
- package/src/migrations/latest/static-website-configurable-waf-encryption/migration.js +418 -0
- package/src/migrations/latest/static-website-configurable-waf-encryption/migration.js.map +1 -0
- package/src/migrations/latest/user-identity-configurable-mfa/metadata.json +3 -0
- package/src/migrations/latest/user-identity-configurable-mfa/migration.d.ts +6 -0
- package/src/migrations/latest/user-identity-configurable-mfa/migration.js +362 -0
- package/src/migrations/latest/user-identity-configurable-mfa/migration.js.map +1 -0
- package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +90 -9
- package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +90 -9
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +259 -48
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.spec.ts.snap +37 -7
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +26 -0
- package/src/utils/dynamodb-constructs/files/cdk/core/dynamodb.ts.template +23 -3
- package/src/utils/dynamodb-constructs/files/terraform/app/dynamodb/__nameKebabCase__/__nameKebabCase__.tf.template +27 -1
- package/src/utils/dynamodb-constructs/files/terraform/core/dynamodb/dynamodb.tf.template +39 -5
- package/src/utils/identity-constructs/files/cdk/core/user-identity.ts.template +41 -7
- package/src/utils/identity-constructs/files/terraform/core/user-identity/identity/identity.tf.template +48 -13
- package/src/utils/identity-constructs/files/terraform/core/user-identity/main.tf.template +26 -0
- package/src/utils/website-constructs/files/cdk/app/static-websites/__websiteNameKebabCase__.ts.template +11 -2
- package/src/utils/website-constructs/files/cdk/core/static-website.ts.template +47 -10
- package/src/utils/website-constructs/files/terraform/app/static-websites/__websiteNameKebabCase__/__websiteNameKebabCase__.tf.template +55 -0
- package/src/utils/website-constructs/files/terraform/core/static-website/static-website.tf.template +57 -15
package/src/utils/website-constructs/files/terraform/core/static-website/static-website.tf.template
CHANGED
|
@@ -35,6 +35,41 @@ variable "acm_certificate_arn" {
|
|
|
35
35
|
default = null
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
variable "enable_waf" {
|
|
39
|
+
description = "Whether to protect the CloudFront distribution with an AWS WAF Web ACL."
|
|
40
|
+
type = bool
|
|
41
|
+
default = true
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
variable "encryption" {
|
|
45
|
+
description = "Server-side encryption for the website and distribution log buckets. One of KMS or S3_MANAGED."
|
|
46
|
+
type = string
|
|
47
|
+
default = "KMS"
|
|
48
|
+
|
|
49
|
+
validation {
|
|
50
|
+
condition = contains(["KMS", "S3_MANAGED"], var.encryption)
|
|
51
|
+
error_message = "encryption must be one of KMS or S3_MANAGED."
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
variable "kms_key_arn" {
|
|
56
|
+
description = "ARN of an existing KMS key used to encrypt the website and distribution log buckets when encryption is KMS. When not provided and create_kms_key is true, a new key is created. Note that a customer-supplied key must already grant the CloudWatch Logs, S3 and CloudFront service principals the necessary permissions in its own key policy."
|
|
57
|
+
type = string
|
|
58
|
+
default = null
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
variable "create_kms_key" {
|
|
62
|
+
description = "Whether to create a KMS key for the website. Only applies when encryption is KMS. Set to false when supplying kms_key_arn."
|
|
63
|
+
type = bool
|
|
64
|
+
default = true
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
variable "enable_key_rotation" {
|
|
68
|
+
description = "Whether the automatically created KMS key has rotation enabled. Only applies when encryption is KMS and create_kms_key is true."
|
|
69
|
+
type = bool
|
|
70
|
+
default = true
|
|
71
|
+
}
|
|
72
|
+
|
|
38
73
|
# Content-Security-Policy enforced on all responses. Restricts scripts and
|
|
39
74
|
# framing to mitigate XSS and clickjacking, while permitting HTTPS/WSS calls
|
|
40
75
|
# (connect-src) to AWS service endpoints such as API Gateway, Cognito and
|
|
@@ -46,6 +81,13 @@ locals {
|
|
|
46
81
|
# Delivery source/destination names have a 60 character maximum. Truncate the
|
|
47
82
|
# website name so the longest delivery name stays within the limit.
|
|
48
83
|
access_logs_name_prefix = substr(lower(var.website_name), 0, 16)
|
|
84
|
+
|
|
85
|
+
create_website_key = var.encryption == "KMS" && var.create_kms_key
|
|
86
|
+
website_kms_key_arn = (
|
|
87
|
+
var.encryption != "KMS" ? null :
|
|
88
|
+
local.create_website_key ? aws_kms_key.website_key[0].arn :
|
|
89
|
+
var.kms_key_arn
|
|
90
|
+
)
|
|
49
91
|
}
|
|
50
92
|
|
|
51
93
|
|
|
@@ -56,9 +98,11 @@ data "aws_region" "current" {}
|
|
|
56
98
|
|
|
57
99
|
# KMS Key for encryption
|
|
58
100
|
resource "aws_kms_key" "website_key" {
|
|
101
|
+
count = local.create_website_key ? 1 : 0
|
|
102
|
+
|
|
59
103
|
description = "KMS key for ${var.website_name} website encryption"
|
|
60
104
|
deletion_window_in_days = 7
|
|
61
|
-
enable_key_rotation =
|
|
105
|
+
enable_key_rotation = var.enable_key_rotation
|
|
62
106
|
|
|
63
107
|
policy = jsonencode({
|
|
64
108
|
Version = "2012-10-17"
|
|
@@ -131,8 +175,10 @@ resource "aws_kms_key" "website_key" {
|
|
|
131
175
|
}
|
|
132
176
|
|
|
133
177
|
resource "aws_kms_alias" "website_key_alias" {
|
|
178
|
+
count = local.create_website_key ? 1 : 0
|
|
179
|
+
|
|
134
180
|
name = "alias/${lower(var.website_name)}-website-key-${random_id.unique_suffix.hex}"
|
|
135
|
-
target_key_id = aws_kms_key.website_key.key_id
|
|
181
|
+
target_key_id = aws_kms_key.website_key[0].key_id
|
|
136
182
|
}
|
|
137
183
|
|
|
138
184
|
# CloudWatch log group receiving S3 server access logs for the website and
|
|
@@ -140,7 +186,7 @@ resource "aws_kms_alias" "website_key_alias" {
|
|
|
140
186
|
resource "aws_cloudwatch_log_group" "access_logs" {
|
|
141
187
|
name = "/aws/s3/${lower(var.website_name)}-access-logs-${random_id.bucket_suffix.hex}"
|
|
142
188
|
retention_in_days = 365
|
|
143
|
-
kms_key_id =
|
|
189
|
+
kms_key_id = local.website_kms_key_arn
|
|
144
190
|
}
|
|
145
191
|
|
|
146
192
|
resource "random_id" "unique_suffix" {
|
|
@@ -177,8 +223,8 @@ resource "aws_s3_bucket_server_side_encryption_configuration" "website_encryptio
|
|
|
177
223
|
|
|
178
224
|
rule {
|
|
179
225
|
apply_server_side_encryption_by_default {
|
|
180
|
-
kms_master_key_id =
|
|
181
|
-
sse_algorithm = "aws:kms"
|
|
226
|
+
kms_master_key_id = var.encryption == "KMS" ? local.website_kms_key_arn : null
|
|
227
|
+
sse_algorithm = var.encryption == "KMS" ? "aws:kms" : "AES256"
|
|
182
228
|
}
|
|
183
229
|
}
|
|
184
230
|
}
|
|
@@ -242,8 +288,8 @@ resource "aws_s3_bucket_server_side_encryption_configuration" "distribution_logs
|
|
|
242
288
|
|
|
243
289
|
rule {
|
|
244
290
|
apply_server_side_encryption_by_default {
|
|
245
|
-
kms_master_key_id =
|
|
246
|
-
sse_algorithm = "aws:kms"
|
|
291
|
+
kms_master_key_id = var.encryption == "KMS" ? local.website_kms_key_arn : null
|
|
292
|
+
sse_algorithm = var.encryption == "KMS" ? "aws:kms" : "AES256"
|
|
247
293
|
}
|
|
248
294
|
}
|
|
249
295
|
}
|
|
@@ -313,6 +359,8 @@ resource "aws_s3_bucket_policy" "distribution_logs_ssl_policy" {
|
|
|
313
359
|
|
|
314
360
|
# WAF Web ACL (must be in us-east-1 for CloudFront)
|
|
315
361
|
resource "aws_wafv2_web_acl" "cloudfront_waf" {
|
|
362
|
+
count = var.enable_waf ? 1 : 0
|
|
363
|
+
|
|
316
364
|
#checkov:skip=CKV2_AWS_31:WAF logging disabled
|
|
317
365
|
provider = aws.us_east_1
|
|
318
366
|
name = "${lower(var.website_name)}-cloudfront-waf-${random_id.unique_suffix.hex}"
|
|
@@ -437,7 +485,7 @@ resource "aws_cloudfront_distribution" "website" {
|
|
|
437
485
|
enabled = true
|
|
438
486
|
is_ipv6_enabled = true
|
|
439
487
|
default_root_object = "index.html"
|
|
440
|
-
web_acl_id = aws_wafv2_web_acl.cloudfront_waf.arn
|
|
488
|
+
web_acl_id = var.enable_waf ? aws_wafv2_web_acl.cloudfront_waf[0].arn : null
|
|
441
489
|
aliases = var.custom_domain_names
|
|
442
490
|
|
|
443
491
|
logging_config {
|
|
@@ -495,12 +543,6 @@ resource "aws_cloudfront_distribution" "website" {
|
|
|
495
543
|
Name = "${lower(var.website_name)}-distribution-${random_id.unique_suffix.hex}"
|
|
496
544
|
}
|
|
497
545
|
|
|
498
|
-
lifecycle {
|
|
499
|
-
replace_triggered_by = [
|
|
500
|
-
aws_wafv2_web_acl.cloudfront_waf
|
|
501
|
-
]
|
|
502
|
-
}
|
|
503
|
-
|
|
504
546
|
# CloudFront validates access to the distribution logs bucket when it
|
|
505
547
|
# creates the distribution.
|
|
506
548
|
depends_on = [
|
|
@@ -773,5 +815,5 @@ output "cloudfront_domain_name" {
|
|
|
773
815
|
|
|
774
816
|
output "waf_web_acl_arn" {
|
|
775
817
|
description = "ARN of the WAF Web ACL"
|
|
776
|
-
value = aws_wafv2_web_acl.cloudfront_waf.arn
|
|
818
|
+
value = var.enable_waf ? aws_wafv2_web_acl.cloudfront_waf[0].arn : null
|
|
777
819
|
}
|