[英]How to get an AWS SSM Key Arn from an Alias using CloudFormation?
[英]Fetch AWS SSM Parameter using ansible and using aws profile or arn
嘗試使用 ansible 從另一個 AWS 賬戶獲取機密。 我們是否可以選擇使用我是秘密 aws 帳戶的角色 arn 來獲取參數。 因為我們創建的每個實例都將與這個秘密 AWS 賬戶 ARN 相關聯。
IAMSECRETARN : arn:aws:iam::xxxxxxxx:role/service/xxx-xxxx-xxxxx-xxxxx-xxx-79392xx94110xxxx
---
- name: Testing shared Roles
hosts: all
tasks:
- name: lookup a key which doesn't exist failing to store it in a fact
set_fact:
temp_secret: "{{ lookup('aws_ssm', '/xxx/xxx/xxx/ansible-tower/admin_password' region='us-east-1', aws_profile='xxx-xxx-xxx') }}"
ignore_errors: true
- name: SSM PARAMS
debug:
msg: "{{ temp_secret }}"
而不是“profile”需要使用“arn”或任何其他沒有秘密和訪問密鑰的方法
我現在使用以下代碼:
---
- name: ssm parameter
hosts: localhost
gather_facts: false
connection: local
tasks:
- sts_assume_role:
role_arn: "arn:aws:iam::xxxxxxx:role/xxxxx/xxxxxx"
role_session_name: "ssm"
region: us-east-1
register: assumed_role
no_log: true
- name: lookup ssm parameter
debug: msg="{{ lookup('aws_ssm', '/xxx/xxx/xxx/xxxx/database_password', region='us-east-1', aws_access_key=assumed_role.sts_creds.access_key, aws_secret_key=assumed_role.sts_creds.secret_key, aws_security_token=assumed_role.sts_creds.session_token ) }}"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.