Sign in

Ensure that the instance port is exposed

There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.

Check if the instance port is exposed in security groups. If not, modify the security group to expose the port.

cmd = f"aws ec2 describe-instances --instance-ids {instance_id} --query 'Reservations[0].Instances[0].SecurityGroups[*].GroupId' --output text" op = _exe(None, cmd) security_group_list = op.strip() security_group_list = security_group_list.split() print(security_group_list)
copied
  1. 1

    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.
    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
    1
    1. 1.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.
      #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}
      copied
      1.1