Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a new filter plugin that can encrypt and decrypt values using AWS KMS service #55920

wants to merge 2 commits into
base: devel


None yet
2 participants
Copy link

commented Apr 30, 2019


Adding a new filter plugin that can encrypt and decrypt values using AWS KMS service.
This filter plugin can be used to encrypt values using the AWS KMS service and store them within your repository, then decrypt then when you want to use them.



In my_role\defaults\main.yml

encrypted_value: >-
  {{ abcd123abcd13 abcd123abcd13abcd12abcd13
  sadsdsasd | aws_kms_decrypt(KEY_ARN) }}

In my_role\tasks\main.yml

- debug:
    msg: "Decrypted value is {{ encrypted_value }}"

Same can be done for encrypting values.


In my_role\tasks\main.yml

- debug:
    msg: "Encrypted value is {{ 'abc123abc123abc123' | aws_kms_encrypt(KEY_ARN) }}"


You can call aws_kms_encrypt and aws_kms_encrypt from this plugin with following variables.

  • Mandatory - ciphertext (str): Encrypted item to decrypt.
  • Mandatory - key_arn (str): AWS ARN to the KMS key.
  • Optional - region (str): AWS region to use.
  • Optional - profile (str): AWS credential profile to use.
  • Optional - role_arn (str): AWS IAM role to use to get credentials.
  • Optional - aws_access_key (str): AWS access key to use.
  • Optional - aws_secret_key (str): AWS secret key to use.

Getting AWS Credentias will use following order.

profile > role_arn > aws_access_key and aws_secret_key > instance IAM profile or default profile


Related to #44014 and #54150

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.