Complete the code to specify the source IP range for the firewall rule.
firewall_rule = {
'name': 'allow-ssh',
'sourceRanges': ['[1]'],
'allowed': [{'IPProtocol': 'tcp', 'ports': ['22']}]
}The sourceRanges field expects a CIDR notation IP range. '0.0.0.0/0' means all IP addresses.
Complete the code to specify the target tags for the firewall rule.
firewall_rule = {
'name': 'allow-http',
'targetTags': ['[1]'],
'allowed': [{'IPProtocol': 'tcp', 'ports': ['80']}]
}Target tags specify which instances the rule applies to. 'web-server' is a common tag for HTTP servers.
Fix the error in the protocol specification of the firewall rule.
firewall_rule = {
'name': 'allow-icmp',
'allowed': [{'IPProtocol': '[1]'}]
}The ICMP protocol is specified as 'icmp' in firewall rules, not 'http' or others.
Fill both blanks to define a firewall rule allowing TCP traffic from a specific source range to target instances.
firewall_rule = {
'name': 'allow-custom',
'sourceRanges': ['[1]'],
'targetTags': ['[2]'],
'allowed': [{'IPProtocol': 'tcp', 'ports': ['8080']}]
}The sourceRanges should be a valid CIDR range like '10.1.0.0/16'. The targetTags should match the instances, here 'ssh-server'.
Fill all three blanks to create a firewall rule allowing UDP traffic on port 53 from any source to DNS servers.
firewall_rule = {
'name': 'allow-dns',
'sourceRanges': ['[1]'],
'targetTags': ['[2]'],
'allowed': [{'IPProtocol': '[3]', 'ports': ['53']}]
}The sourceRanges '0.0.0.0/0' allows all IPs. Target tag 'dns-server' identifies DNS instances. Protocol 'udp' is used for DNS queries.