@aws/nx-plugin-mcp 1.0.0-rc.19 → 1.0.0-rc.20
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.
|
@@ -318,8 +318,8 @@ Terraform's AWS provider does not have a first-class "build and push a Docker im
|
|
|
318
318
|
|
|
319
319
|
1. The project's `build` target runs `docker build`, producing a local image tagged `my-scope-my-project:latest`.
|
|
320
320
|
2. An `aws_ecr_repository` to hold the image.
|
|
321
|
-
3. A `null_resource` with a `local-exec` provisioner that authenticates to ECR, re-tags the locally-built image, and pushes it.
|
|
322
|
-
4. The downstream resource (e.g. `aws_ecs_task_definition`) references
|
|
321
|
+
3. A `null_resource` with a `local-exec` provisioner that authenticates to ECR, re-tags the locally-built image with its content digest, and pushes it.
|
|
322
|
+
4. The downstream resource (e.g. `aws_ecs_task_definition`) references the image by its immutable, digest-based tag.
|
|
323
323
|
|
|
324
324
|
```d2
|
|
325
325
|
direction: down
|
|
@@ -361,7 +361,7 @@ infra.repo -> ecr
|
|
|
361
361
|
```hcl
|
|
362
362
|
resource "aws_ecr_repository" "repo" {
|
|
363
363
|
name = "my-project-repository"
|
|
364
|
-
image_tag_mutability = "
|
|
364
|
+
image_tag_mutability = "IMMUTABLE"
|
|
365
365
|
force_delete = true
|
|
366
366
|
}
|
|
367
367
|
|
|
@@ -370,24 +370,30 @@ data "external" "docker_digest" {
|
|
|
370
370
|
program = ["sh", "-c", "echo '{\"digest\":\"'$(docker inspect my-scope-my-project:latest --format '{{.Id}}')'\"}'"]
|
|
371
371
|
}
|
|
372
372
|
|
|
373
|
+
locals {
|
|
374
|
+
# Content-based, immutable image tag derived from the local image digest
|
|
375
|
+
image_tag = replace(data.external.docker_digest.result.digest, "sha256:", "")
|
|
376
|
+
}
|
|
377
|
+
|
|
373
378
|
resource "null_resource" "docker_publish" {
|
|
374
379
|
triggers = {
|
|
375
380
|
docker_digest = data.external.docker_digest.result.digest
|
|
376
381
|
repository_url = aws_ecr_repository.repo.repository_url
|
|
382
|
+
image_tag = local.image_tag
|
|
377
383
|
}
|
|
378
384
|
|
|
379
385
|
provisioner "local-exec" {
|
|
380
386
|
command = <<-EOT
|
|
381
387
|
aws ecr get-login-password --region ${data.aws_region.current.id} \
|
|
382
388
|
| docker login --username AWS --password-stdin ${self.triggers.repository_url}
|
|
383
|
-
docker tag my-scope-my-project:latest ${self.triggers.repository_url}
|
|
384
|
-
docker push ${self.triggers.repository_url}
|
|
389
|
+
docker tag my-scope-my-project:latest ${self.triggers.repository_url}:${self.triggers.image_tag}
|
|
390
|
+
docker push ${self.triggers.repository_url}:${self.triggers.image_tag}
|
|
385
391
|
EOT
|
|
386
392
|
}
|
|
387
393
|
}
|
|
388
394
|
```
|
|
389
395
|
|
|
390
|
-
The `data.external.docker_digest` block ensures the `null_resource` re-runs whenever the local image hash changes, triggering a new push on every meaningful code change.
|
|
396
|
+
The `data.external.docker_digest` block ensures the `null_resource` re-runs whenever the local image hash changes, triggering a new push on every meaningful code change. The image is pushed under an immutable, content-based tag derived from its digest, so the ECR repository can use `IMMUTABLE` tag mutability and reject any attempt to overwrite an existing tag.
|
|
391
397
|
|
|
392
398
|
:::note[Running bundle before apply]
|
|
393
399
|
`nx apply <project>` requires the image tag `my-scope-my-project:latest` to already exist locally. Run `nx build my-project` (or `nx docker my-project`) before `nx apply <project>`.
|
|
@@ -128,7 +128,9 @@ cloudfront -> s3
|
|
|
128
128
|
|
|
129
129
|
#### Security Headers
|
|
130
130
|
|
|
131
|
-
The CloudFront distribution applies a response headers policy that sets `Strict-Transport-Security`, `X-Content-Type-Options`, `X-Frame-Options: DENY
|
|
131
|
+
The CloudFront distribution applies a response headers policy that sets `Strict-Transport-Security`, `X-Content-Type-Options`, `X-Frame-Options: DENY`, `Referrer-Policy` and a `Content-Security-Policy` on all responses.
|
|
132
|
+
|
|
133
|
+
A default `Content-Security-Policy` is enforced. It restricts scripts and framing to mitigate XSS and clickjacking, while permitting HTTPS and WSS connections so the website can call AWS service endpoints (such as API Gateway, Cognito and Bedrock AgentCore) whose URLs are only known at deploy time. To adjust the policy (for example to tighten `connect-src` to your specific origins), edit the `content_security_policy` value in your generated `static-website.ts` (CDK) or `static-website.tf` (Terraform).
|
|
132
134
|
|
|
133
135
|
`runtime-config.json` is served with `Cache-Control: no-cache` so that browsers always fetch the latest configuration after a redeploy, rather than using a stale cached copy.
|
|
134
136
|
|
|
@@ -6,7 +6,7 @@ import Infrastructure from '@components/infrastructure.astro';
|
|
|
6
6
|
For REST APIs, the generated construct associates an [AWS WAFv2](https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html) Web ACL with the API Gateway stage by default. The Web ACL uses the AWS managed default ruleset ([`AWSManagedRulesCommonRuleSet`](https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups-baseline.html#aws-managed-rule-groups-baseline-crs) and [`AWSManagedRulesKnownBadInputsRuleSet`](https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups-baseline.html#aws-managed-rule-groups-baseline-known-bad-inputs)), providing protection against common web exploits including the OWASP Top 10. WAF request logs are written to a CloudWatch Logs group.
|
|
7
7
|
|
|
8
8
|
:::caution[SizeRestrictions_BODY deviation from defaults]
|
|
9
|
-
The `SizeRestrictions_BODY` rule from `AWSManagedRulesCommonRuleSet` is overridden to `Count` rather than `Block`, since the rule's 8 KB limit is too restrictive for most APIs. Oversized requests will still be recorded as metrics so you can monitor them. See the [AWS WAF body size limits](https://docs.aws.amazon.com/waf/latest/developerguide/waf-rule-statement-oversize-handling.html) guide for more details.
|
|
9
|
+
The `SizeRestrictions_BODY` rule from `AWSManagedRulesCommonRuleSet` is overridden to `Count` rather than `Block`, since the rule's 8 KB limit is too restrictive for most APIs. Oversized requests will still be recorded as metrics so you can monitor them. See the [AWS WAF body size limits](https://docs.aws.amazon.com/waf/latest/developerguide/waf-rule-statement-oversize-handling.html) guide for more details. API Gateway natively enforces its [maximum payload size of 10 MB](https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html), returning a `413` for larger requests.
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
12
|
You can edit the generated rest-api construct to add, remove, or adjust rules (for example, to add [rate-based rules](https://docs.aws.amazon.com/waf/latest/developerguide/waf-rule-statement-type-rate-based.html) or additional managed rule groups).
|