Skip to content

fix(deploy): define missing AllowedCIDR parameter in CloudFormation template - #3

Open
zjdMASTER wants to merge 1 commit into
aws-samples:mainfrom
zjdMASTER:fix/cfn-undefined-allowedcidr-param
Open

fix(deploy): define missing AllowedCIDR parameter in CloudFormation template#3
zjdMASTER wants to merge 1 commit into
aws-samples:mainfrom
zjdMASTER:fix/cfn-undefined-allowedcidr-param

Conversation

@zjdMASTER

Copy link
Copy Markdown

What is wrong

deploy/cfn-agentic-data.yaml references an AllowedCIDR parameter in the ALB security group ingress rule:

# ALBSecurityGroup.SecurityGroupIngress (was line 327)
CidrIp: !Ref AllowedCIDR

but AllowedCIDR is never declared in the Parameters block (only VpcCidr exists). CloudFormation treats this as an unresolved resource dependency and rejects the template at create/validate time, so the one-click deploy in deploy/deploy.sh (which runs aws cloudformation deploy --template-file cfn-agentic-data.yaml ...) fails for both EC2 and ECS modes before any resource is created. deploy.sh also never passes an AllowedCIDR override, so the parameter needs a default.

A second, related defect in the same security group: the ingress only opened TCP 443, but the stack's only listener (ALBListener) is HTTP on port 80, and the stack output / deploy/README.md advertise http://<alb-dns>. Even once the template parses, the ALB would be unreachable because port 80 is not permitted inbound.

The fix

  • Declare the missing AllowedCIDR parameter (CIDR-validated, default 10.0.0.0/8, consistent with the sibling cdk/deploy.sh default and the template's existing "never 0.0.0.0/0" guidance).
  • Add an ingress rule for port 80 to match the HTTP listener the stack actually creates. Port 443 is retained for the documented post-deploy ACM/HTTPS listener.

How verified

  • Reproduced the failure with cfn-lint 1.53.1 on the original template: E1020 'AllowedCIDR' is not one of [...] at cfn-agentic-data.yaml:327.
  • After the change, cfn-lint deploy/cfn-agentic-data.yaml exits 0 with no findings.

Not verified

A full live aws cloudformation deploy was not run (no AWS account was used), so end-to-end stack creation and actual ALB reachability were not exercised. The change is limited to the template parameter declaration and security-group ingress; it was validated statically with cfn-lint.

The CloudFormation template referenced an AllowedCIDR parameter in the
ALB security group ingress rule, but the parameter was never declared.
CloudFormation rejects the template with an unresolved-dependency error,
so the one-click deploy (deploy/deploy.sh) fails for both EC2 and ECS
modes before any resource is created.

Declare the AllowedCIDR parameter, and open the ALB security group on
port 80 to match the HTTP listener that the stack actually creates (the
ingress previously only permitted 443, for which there is no listener,
leaving the ALB unreachable). Port 443 is kept for the documented
post-deploy ACM/HTTPS listener.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant