Skip to content
check-circle

GitHub Action

Add IP address to EC2 security group

v1.2 Latest version

Add IP address to EC2 security group

check-circle

Add IP address to EC2 security group

Add IP address and port to EC2 security group. This action assumes that the AWS CLI is already installed and configured

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Add IP address to EC2 security group

uses: twosense/add-ip-to-ec2-security-group@v1.2

Learn more about this action in twosense/add-ip-to-ec2-security-group

Choose a version

Add IP to EC2 security group action

This action adds an IP address on a specific port to an EC2 security group. If no IP address is provided, the action will use the IP address of the machine running the action.

The post action will remove the IP address from the security group.

Note: this action assumes that the AWS CLI is installed and configured previously in the workflow.

Inputs


security-group-id

Required

The EC2 security group ID to add the IP to.

port

Required

The port to open on the security group.

ip

The IP address to add to the security group. If no IP address is provided, the action will use the IP address of the machine running the action.

protocol

The protocol to use for the security group rule. Defaults to tcp.

Usage


Add the following step to your workflow:

    - name: Add IP to EC2 security group
      uses: twosense/add-ip-to-ec2-security-group@v1
      with:
        security-group-id: ${{ secrets.SECURITY_GROUP_ID }}
        port: 22