Skip to main content

A lemniscat plugin to run awscli scripts

Project description

lemniscat.plugin.awscli

A plugin to operate AWS services through AWS cli into a lemniscat workflow

Description

This plugin allows you to operate AWS services through AWS cli into a lemniscat manifest.

Usage

Pre-requisites

In order to use this plugin, you need to have an AWS account and an AWS user. You can create a user using the AWS CLI, PowerShell, or the AWS console. The service principal is used to authenticate the AWS CLI to your AWS account.

After that you to be sure that you have the AWS CLI installed on your agent. You can install it using the following command:

Linux

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

Windows

msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi

You need also set environment variables to authenticate the AWS CLI to your AWS account.

  • AWS_ACCESS_KEY_ID : The access key ID of the AWS user
  • AWS_SECRET_ACCESS_KEY : The secret access key of the AWS user
  • AWS_DEFAULT_REGION : The default region to use, for example us-west-2

You need to add plugin into the required section of your manifest file.

requirements:
  - name: lemniscat.plugin.awscli
    version: 0.1.0.9

Running powershell commands with AWS CLI

- task: awscli
  displayName: 'AWS CLI'
  steps:
    - run
  parameters:
    scripttype: pwsh
    commandtype: inline
    script: |
      $version = az --version
      Write-Host "AWS CLI version: $version"

Running powershell script with AWS CLI

- task: awscli
  displayName: 'AWS CLI'
  steps:
    - run
  parameters:
    scripttype: pwsh
    commandtype: file
    filePath: ${{ workingdirectory }}/scripts/ClearAWSBucket.ps1
    fileParams:
      bucketname: ${{ bucketName }}

Running powershell commmands and pass variables through json file

[!NOTE] This feature is particulary recommand when you need to manipulate complexe variable with your task. You can access to the variables in the json file by using the following command:

$location = Get-Location
$variables = Get-Content "$($location.path)/vars.json" | ConvertFrom-Json -Depth 100
- task: awscli
  displayName: 'AWS CLI'
  steps:
    - run
  parameters:
    scripttype: pwsh
    commandtype: inline
    script: |
      $location = Get-Location
      $variables = Get-Content "$($location.path)/vars.json" | ConvertFrom-Json -Depth 100
      $version = az --version
      Write-Host "AWS CLI version: $version"
    storeVariablesInFile:
      format: json
      withSecrets: false

Inputs

Parameters

  • scripttype: The type of the script to run. It can be only pwsh (for the moment)
  • commandtype: The type of the command to run. It can be inline or file
  • script: The script to run. It can be a powershell command line. It is used only if commandtype is inline
  • filePath: The path of the powershell script file (*.ps1) to run. It is used only if commandtype is file
  • fileParams: The parameters to pass to the powershell script file. It is used only if commandtype is file
  • storeVariablesInFile: Describe the way to store the variables in a file to used in the task.

StoreVariablesInFile

  • format: The format of the file to store the variables. It can be json or yaml
  • withSecrets: A boolean value to indicate if the secrets should be stored in the file. It can be true or false

Outputs

You can push variables to the lemniscat runtime in order to be used after by other tasks. To do that, you need to use Write-Host command in your powershell script to push variables to the lemniscat runtime. You must use the following format to push variables to the lemniscat runtime: [lemniscat.pushvar] <variableName>=<variableValue>

For example:

Write-Host "[lemniscat.pushvar] workspaceExist=$workspaceExist"

You can specify the sensitivity of the variable by adding secret like this : [lemniscat.pushvar.secret] <variableName>=<variableValue>

For example:

Write-Host "[lemniscat.pushvar.secret] storageAccountKey=$storageAccountKey"

By default all variable are considered as string. If you want to specify the type of the variable, you can add the type after the variable name like this: [lemniscat.pushvar(<variableType>)] <variableName>=<variableValue>

variableType can be string, int, bool, float, json (for complexe object)

For example:

Write-Host "[lemniscat.pushvar(int)] numberOfFiles=$numberOfFiles"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lemniscat_plugin_awscli-0.3.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lemniscat.plugin.awscli-0.3.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file lemniscat_plugin_awscli-0.3.0.tar.gz.

File metadata

  • Download URL: lemniscat_plugin_awscli-0.3.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for lemniscat_plugin_awscli-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e974159cf36703fc6adb6ae3a4cb896b3b6019fd6b75de41242cc1390eeaa9fc
MD5 c07db7bd46ef7609610afc167e1d784b
BLAKE2b-256 24d38b5faa3ec1ef527b9275e05bee1ef378a9b85f4144c15b69a4b697b723a7

See more details on using hashes here.

File details

Details for the file lemniscat.plugin.awscli-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for lemniscat.plugin.awscli-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea54bcdc067ffabc40a851330307db6a62dc8f5969b7ff622220d451dc55824f
MD5 9919760f298a38779f9b1a52ba9d47d5
BLAKE2b-256 c8d5ad556bce32bd3b045e4bd745424081990aa26d0d0b90d91be3d553dc8268

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page