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 #54150

Open
wants to merge 10 commits into
base: devel
from

Conversation

Projects
None yet
3 participants
@achinthagunasekara
Copy link
Contributor

achinthagunasekara commented Mar 21, 2019

SUMMARY

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.

Example

Decrypting

In my_role\defaults\main.yml

encrypted_value: >-
  {{ abcd123abcd13 abcd123abcd13abcd12abcd13
  abcd123abcd13abcd123abcd13abcd123ab1d1312
  abcd123abcd13abcd123abcd13abcd123ssdsas12
  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.

Encrypting

In my_role\tasks\main.yml

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

Arguments

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

ADDITIONAL INFORMATION

Related to #44014

@Akasurde
Copy link
Member

Akasurde left a comment

Could you please add integration tests for this change? Thanks.

Show resolved Hide resolved lib/ansible/plugins/lookup/aws_kms_decrypt.py Outdated
Show resolved Hide resolved lib/ansible/plugins/lookup/aws_kms_decrypt.py Outdated
Show resolved Hide resolved lib/ansible/plugins/lookup/aws_kms_decrypt.py Outdated
Show resolved Hide resolved lib/ansible/plugins/lookup/aws_kms_decrypt.py
Show resolved Hide resolved lib/ansible/plugins/lookup/aws_kms_decrypt.py Outdated
Show resolved Hide resolved lib/ansible/plugins/lookup/aws_kms_decrypt.py Outdated
Show resolved Hide resolved lib/ansible/plugins/lookup/aws_kms_decrypt.py
Show resolved Hide resolved lib/ansible/plugins/lookup/aws_kms_encrypt.py Outdated
Show resolved Hide resolved lib/ansible/plugins/lookup/aws_kms_encrypt.py Outdated
Show resolved Hide resolved lib/ansible/plugins/lookup/aws_kms_encrypt.py Outdated
Archie Gunasekara
@achinthagunasekara

This comment has been minimized.

Copy link
Contributor Author

achinthagunasekara commented Mar 25, 2019

@Akasurde I have updated the PR for your comments. Can you please take another look?

Thanks :)

Archie Gunasekara added some commits Mar 25, 2019

Archie Gunasekara
Archie Gunasekara
@achinthagunasekara

This comment has been minimized.

Copy link
Contributor Author

achinthagunasekara commented Mar 25, 2019

@Akasurde I have updated the PR for your latest comments. Can you please take another look?

Thanks :)

achinthagunasekara added some commits Mar 25, 2019

@achinthagunasekara

This comment has been minimized.

Copy link
Contributor Author

achinthagunasekara commented Mar 29, 2019

@Akasurde I have updated the PR for your latest comments. Can you please take another look?

Thanks :)

@achinthagunasekara

This comment has been minimized.

Copy link
Contributor Author

achinthagunasekara commented Apr 9, 2019

@Akasurde I have updated the PR for your latest comments. Can you please take another look?

Thanks :)

1 similar comment
@achinthagunasekara

This comment has been minimized.

Copy link
Contributor Author

achinthagunasekara commented Apr 16, 2019

@Akasurde I have updated the PR for your latest comments. Can you please take another look?

Thanks :)

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.