ChiefGyk3D aee452002d feat(telemetry): opt-in node exporter and security-group-sourced metrics rules on AWS (#99) (#154) před 1 měsícem
..
tests aee452002d feat(telemetry): opt-in node exporter and security-group-sourced metrics rules on AWS (#99) (#154) před 1 měsícem
.terraform.lock.hcl da21a6e87d feat(aws): vpc, firewall and connector modules (phase 3a of #22) (#45) před 1 měsícem
README.md aee452002d feat(telemetry): opt-in node exporter and security-group-sourced metrics rules on AWS (#99) (#154) před 1 měsícem
main.tf aee452002d feat(telemetry): opt-in node exporter and security-group-sourced metrics rules on AWS (#99) (#154) před 1 měsícem
outputs.tf aee452002d feat(telemetry): opt-in node exporter and security-group-sourced metrics rules on AWS (#99) (#154) před 1 měsícem
variables.tf aee452002d feat(telemetry): opt-in node exporter and security-group-sourced metrics rules on AWS (#99) (#154) před 1 měsícem
versions.tf da21a6e87d feat(aws): vpc, firewall and connector modules (phase 3a of #22) (#45) před 1 měsícem

README.md

firewall (AWS)

Packet filtering for a group of machines. Part of the provider module contract (design section 5). Mocked-provider tests only: this module has never been applied to a real AWS account.

DigitalOcean answers the three filtering questions with one tag. AWS splits them: a security group is attached to a machine's network interface, and a rule names its source or destination as an address range or as another security group.

Role Meaning DigitalOcean object AWS object
rule_targets What the rules attach to The tag the firewall applies to (tags) The security group's id. A machine lists it in vpc_security_group_ids when it launches.
source_members Who may reach the targets, by membership source_tags of the inbound rules The security group named as the source of an aws_vpc_security_group_ingress_rule (referenced_security_group_id). Here, this group itself.
destination_members What the targets may reach, by membership destination_tags of the outbound rules The security group named as the destination of an aws_vpc_security_group_egress_rule. Here, this group itself.
Internet egress Rules by address range Outbound rules to 0.0.0.0/0 and ::/0 aws_vpc_security_group_egress_rule to 0.0.0.0/0: tcp 443, 80, 53 and udp 53, 123, plus extra_outbound_rules. IPv4 only; the VPC has no IPv6.

Contract outputs: id, name, rule_targets, source_members, destination_members.

Provider extensions

vpc_id (input): a security group belongs to one VPC. Member rules are inbound_from_member_rules and outbound_to_member_rules; both name this group itself, never an address, so only machines wearing the group can use them.

inbound_from_other_groups takes [{protocol, port_range, security_group_id}] (default empty) to admit members of a different security group, one rule per entry. The source is always referenced_security_group_id: the variable has no address field, the rule resource sets no cidr_ipv4, cidr_ipv6 or prefix_list_id, and tests/test_metrics_firewall_aws.py scans the source for that. inbound_rules and source_members list these rules too. A source equal to this module's own group is refused by a precondition on the rule (use inbound_from_member_rules for that; the check runs at plan once the group exists, at apply on its first creation). The group must exist in the same VPC or a peered one. Changing a rule's source group changes its key (remove, then add); a caller that swaps the group should apply once with the list empty first.

The id and rule_targets outputs declare depends_on for all the rule resources, so an instance in the same apply launches after its egress rules exist (ordering UNVERIFIED until an apply; the test checks the declaration only).

Ports are validated as numbers from 0 to 65535 with the start not above the end.

Inbound is deny-all: the group has no inbound rule unless a member rule asks for one. Every rule is a separate rule resource and the group has no inline ingress or egress block. AWS gives a new group one allow-all outbound rule; the AWS provider removes it when it creates a group in a VPC, so the only egress is what the module lists. UNVERIFIED against a live account. The tests prove the module declares no every-protocol rule (a protocol outside tcp and udp is rejected by validation) and no inline rule block; whether the allow-all rule is really gone is only provable by an apply and describe-security-group-rules, which the phase 4 apply must record.

A security group does not filter Amazon's DNS resolver, DHCP, the instance metadata service or the time service.

Phase 4 acceptance record

Mocked tests cannot show what AWS does. The first real apply must record each of these, with the command output kept with the apply notes, before the module is called verified:

  • aws ec2 describe-security-group-rules for the group: exactly the five outbound rules (plus any member rules), no every-protocol (-1) egress rule, no inbound rule from 0.0.0.0/0 or ::/0.
  • Known limit: a rule added to the group outside the code is not detected as drift (the group does not declare egress = [], because that would fight the separate rule resources). The describe output above is the check, and it should be repeated after any manual console change.