Giter VIP home page Giter VIP logo

aws-security-group-updater's Introduction

AWS Security Group Updater

Docker image to automatically update an AWS security group to allow the host IP.

Configuration

Env Name Description
AWS_ACCESS_KEY_ID IAM credentials with permission to edit the security group.
AWS_SECRET_ACCESS_KEY IAM credentials with permission to edit the security group.
AWS_DEFAULT_REGION Security group's region.
SG_UPDATE_GROUP_ID Security group's id.
PROTOCOL Protocol to be allowed (e.g.: tcp)
FROM_PORT Port range start (e.g.: 80)
TO_PORT Port range end (e.g.: 80)
EXIT_ON_FINISH Whether to exit on finish or hang forever (e.g.: true or false)

IAM Policy

Example IAM policy to allow an user to edit a security group.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "sid-0",
            "Effect": "Allow",
            "Action": [
                "ec2:RevokeSecurityGroupIngress",
                "ec2:AuthorizeSecurityGroupEgress",
                "ec2:AuthorizeSecurityGroupIngress",
                "ec2:RevokeSecurityGroupEgress"
            ],
            
            "Resource": "arn:aws:ec2:<region>:<account-id>:security-group/<securiy-group-id>"
        }
    ]
}

Example: k8s DaemonSet

You may create a Kubernetes DaemonSet to ensure every cluster-node registers its IP to the AWS Security Group. Existent nodes and next added ones will register their IPs to the security group.

Note that, when a node is evicted, its IP won't be removed from the security group.

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: aws-security-group-updater
  namespace: default
spec:
  selector:
    matchLabels:
      name: aws-security-group-updater
  template:
    metadata:
      labels:
        name: aws-security-group-updater
    spec:
      tolerations:
      # this toleration is to have the daemonset runnable on master nodes
      # remove it if your masters can't run pods
      - key: node-role.kubernetes.io/master
        operator: Exists
        effect: NoSchedule
      terminationGracePeriodSeconds: 30
      containers:
      - name: aws-security-group-updater
        image: ghcr.io/aguglie/aws-security-group-updater:v1.0.0
        env:
          - name: AWS_ACCESS_KEY_ID
            value: "AXXXXXXXXXXXXXXXXX"
          - name: AWS_SECRET_ACCESS_KEY
            value: "WXXXXXXXXXXXXXXXXXXXX"
          - name: AWS_DEFAULT_REGION
            value: "eu-central-1"
          - name: SG_UPDATE_GROUP_ID
            value: "sg-00000000000000"
          - name: PROTOCOL
            value: "tcp"
          - name: FROM_PORT
            value: "80"
          - name: TO_PORT
            value: "80"
          - name: EXIT_ON_FINISH
            value: "false"
        resources:
          requests:
            cpu: 10m
            memory: 50Mi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.