agent: |
seDVbAVjcqDLl5WWHRoGCheck if the instance port is open
Check if the instance port is open
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.
inputs
outputs
import json
import copy
#port = int(port)
sgl = copy.deepcopy(security_group_list)
security_group_id = sgl[0]
is_allowed = False
for sg_id in security_group_list:
cmd = f'aws ec2 describe-security-groups --filter Name=group-id,Values={sg_id} --query SecurityGroups[*].IpPermissions[*]'
op = _exe(None, cmd)
json_op = json.loads(op)
for sg in json_op:
for rule in sg:
if 'FromPort' in rule:
port_lo = int(rule['FromPort'])
port_hi = port_lo
if 'ToPort' in rule:
port_hi = int(rule['ToPort'])
if port >= port_lo and port <= port_hi:
is_allowed = True
if not is_allowed:
msg = f"The inbound port {port} is BLOCKED by security groups {security_group_list}"
msg_type = "ERROR"
else:
msg = f"The inbound port {port} is ALLOWED by security groups {security_group_list}"
msg_type = "SUCCESS"
context.log(msg_type, msg)
print(msg)
task_title = context.task_title
context.job_context[task_title] = {"msg" : msg, "msg_type" : msg_type}
context.skip_sub_tasks = is_allowed
copied
- 1IiW5Rv4LKUDxxgha3fRZExpose an inbound port on an ec2 instance
1
Expose an inbound port on an ec2 instance
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.inputsoutputs#port = int(port) cmd = f"aws ec2 authorize-security-group-ingress --group-id {security_group_id} --protocol tcp --port {port} --cidr 0.0.0.0/0" op = _exe(None, cmd) msg = f"allowing port {port} in security group {security_group_id}" print(msg) msg_type = "SUCCESS" context.log(msg_type, msg) task_title = context.task_title context.job_context[task_title] = {"msg" : msg, "msg_type" : msg_type}copied1