Giter Site home page Giter Site logo

aws-ssm-send-command's Introduction

AWS SSM Send-Command

This action helps you to execute remote bash command for AWS EC2 instance without SSH or other accessing.

(This action internally uses AWS SSM Send-Command.)

Contents

Requirements

  1. To use this action, you have to set AWS IAM Role AmazonSSMFullAccess to your IAM user.
  2. Also your EC2 Instance must have IAM Role including AmazonSSMFullAccess.

Usage example

name: AWS SSM Send-Command Example

on:
  push:
    branches: [master]

jobs:
  start:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: AWS SSM Send-Command
        uses: peterkimzz/aws-ssm-send-command@master
        id: ssm
        with:
          aws-region: ${{ secrets.AWS_REGION }}
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          instance-ids: ${{ secrets.INSTANCE_ID }}

          working-directory: /home/ubuntu/application
          command: ls -al
          comment: Hello world!

      # Catch SSM outputs
      - name: Get the outputs
        run: echo "The Command id is ${{ steps.ssm.outputs.command-id }}"

Inputs

aws-access-key-id

Required Your IAM access key id.

aws-secret-access-key

Required Your IAM secret access key id.

aws-region

Required AWS EC2 Instance region. (e.g. us-west-1, us-northeast-1, ...)

instance-ids

Required The id of AWS EC2 instance id (e.g i-xxx...)

# single instance
instance-ids: i-0b1f8b18a1d450000

# multiple instances (maxium 50 values)
instance-ids: |
  i-0b1f8b18a1d450000
  i-0b1f8b18a1d450001
  i-0b1f8b18a1d450002

command

Bash command you want to execute in a EC2 instance.

# default
command: echo $(date) >> logs.txt

# restart your pm2 service
command: pm2 restart 0

# or execute shell script
command: /bin/sh restart.sh

working-directory

Where bash command executes.

# default
working-directory: /home/ubuntu

comment

Logging message attached AWS SSM.

# default
comment: Executed by Github Actions

Outputs

command-id

AWS SSM Run-Command id. (uuid type)

# example
6cf26b6f-b68f-4e20-b801-f6ee5318d000

Error Handling

AccessDeniedException

This error occurs when you are not set AWS IAM role about SSM. Please set the IAM permission AmazonSSMFullAccess (recommended)

InvalidInstanceId: null

This error occurs when you are not attach AWS IAM role to your EC2 instance. Please set the IAM role AmazonSSMFullAccess (recommended)

In almost error cases, those issues would be resolved when you set IAM Role to your AWS Account and EC2 IAM Role.

aws-ssm-send-command's People

Contributors

peterkimzz avatar giacomopiccinini avatar handa-kenta avatar dependabot[bot] avatar

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.