Pipe file directly to AWS SSM parameter store?

IF you are using terraform:

data "local_file" "yourkeyfile" {
    filename = "keys/yourkey.pem"
}
resource "aws_ssm_parameter" "aresource-name-for-your-key" {
  name  = "/the/ssm/key"
  type  = "SecureString"
  value = "${data.local_file.yourkeyfile.content}"
}

Remember to crypt yourkey.pem for example using blackbox


Rather than taking the value from stdin can you directly add to the command line arguments?

aws ssm put-parameter \
    --region ap-southeast-1 \
    --name MY_GITHUB_PRIVATE_KEY \
    --type SecureString \
    --key-id alias/aws/ssm \
    --value file://my_github_private.key

Note: --value "$(cat my_github_private.key)" also works


@tkwargs, how to get only value from key.json file and example

aws ssm put-parameter \
    --region ap-southeast-1 \
    --name MY_GITHUB_PRIVATE_KEY \
    --type SecureString \
    --key-id alias/aws/ssm \
    --value "$(cat my_github_private.json file and get value only)"