Sign inSign up

tdmalone/aws-ssm

By tdmalone

•Updated over 7 years ago

A fork of cmattoon/aws-ssm

Image
1

1.7K

tdmalone/aws-ssm repository overview

⁠cmattoon/aws-ssm

Build Status GitHub tag Docker Pulls codecov Go Report Card Maintainability

Updates Kubernetes Secrets with values from AWS Parameter Store

⁠Build Options

  • Helm Chart (recommended): make {lint|install|purge}
  • Go: make test && make build
  • Docker: make container

⁠Helm Chart

⁠Install Helm Chart

First, export required variables, then run make install.

export AWS_REGION=<region>
⁠AWS Credentials

Uses the default credential provider chain⁠

⁠Values

The following chart values may be set. Only the required variables (AWS credentials) need provided by the user. Most of the time, the other defaults should work as-is.

Req'dValueDefaultExampleDescription
YESaws.region""us-west-2The AWS region in which the Pod is deployed
NOaws.access_key""REQUIRED when no other auth method available (e.g., IAM role)
NOaws.secret_key""REQUIRED when no other auth method available (e.g., IAM role)
NOkubeconfig64""The output of $(cat $KUBE_CONFIG | base64). Stored as a Secret
NOmetrics_port9999Serve metrics/healthchecks on this port
NOimage.namecmattoon/aws-ssm/The Docker image to use for the Pod container
NOimage.taglatestThe Docker tag for the image
NOresources{}Kubernetes Resource Requests/Limits
NOrbac.enabledtrueWhether or not to add Kubernetes RBAC stuff
NOssl.mount_hostfalseMounts {ssl.host_path} -> {ssl.mount_path} as hostVolume
NOssl.host_path/etc/ssl/certsThe SSL certs dir on the host
NOssl.mount_path/etc/ssl/certsThe SSL certs dir in the container (dev)

⁠Configuration

The following app config values can be provided via environment variables or CLI flags. CLI flags take precdence over environment variables.

A KUBE_CONFIG and MASTER_URL are only necessary when running outside of the cluster (e.g., dev)

EnvironmentFlagDefaultDescription
AWS_REGION-regionus-west-2The AWS Region
METRICS_URL-metrics-url0.0.0.0:9999Address for healthchecks/metrics
KUBE_CONFIG-kube-configThe path to the kube config file
MASTER_URL-master-urlThe Kubernetes master API URL
LOG_LEVEL-log-levelinfoThe Logrus log level

⁠Basic Usage

  1. Create Parameter in AWS Parameter Store

my-db-password = foobar

  1. Create Kubernetes Secret with Annotations
apiVersion: v1
kind: Secret
metadata:
  name: my-secret
  annotations:
    aws-ssm/k8s-secret-name: my-secret
    aws-ssm/aws-param-name: my-db-password
    aws-ssm/aws-param-type: SecureString
data: {}
  1. Run Binary

  2. A key with the name $ParameterType should have been added to your Secret

apiVersion: v1
kind: Secret
metadata:
  name: my-secret
  annotations:
    aws-ssm/k8s-secret-name: my-secret
    aws-ssm/aws-param-name: my-db-password
    aws-ssm/aws-param-type: SecureString
data:
  SecureString: Zm9vYmFyCg==

⁠Annotations

AnnotationDescriptionDefault
aws-ssm/k8s-secret-nameThe name of the Kubernetes Secret to modify.<none>
aws-ssm/aws-param-nameThe name of the AWS SSM Parameter. May be a path.<none>
aws-ssm/aws-param-typeDetermines how values are parsed, if at all.String
aws-ssm/aws-param-keyRequired if aws-ssm/aws-param-type is SecureStringalias/aws/ssm
⁠AWS Parameter Types

Values for aws-ssm/aws-param-type are:

ValueBehaviorAWS ValueK8S Value(s)
StringNo parsing is performedfoo = barfoo: bar
SecureStringRequires aws-param-keyfoo = barfoo: bar
StringListSplits CSV mappingfoo=bar,bar=baz,baz=batfoo: bar
bar: baz
baz: bat
DirectoryGet multiple values/path/to/values<treats each subkey/value as a String>

⁠Build

make           # Build binary
make container # Build Docker image
make push      # Push Docker image

⁠CA Certificates

For ease of use, the ca-certificates package is installed on the final library/alpine image. If you're having SSL/TLS connection issues, export HOST_SSL_DIR=/etc/ssl/certs before running make install. This will mount the SSL cert directory on the EC2 instance.

Tag summary

Content type

Image

Digest

Size

21.3 MB

Last updated

over 7 years ago

docker pull tdmalone/aws-ssm