如果在AWS Systems Manager的自动化文档中使用变量时,变量未解析,则可能需要检查是否正确地设置了相关参数和权限。以下是一个示例脚本,通过使用EC2实例ID和AWS Systems Manager参数来获取AWS CLI配置文件中所需的信息:
- name: configure-aws-cli
inputs:
InstanceIds:
- "{{ InstanceId }}"
DocumentType: "Command"
DocumentName: "AWS-ConfigureAWSPackage"
OutputS3BucketName: "{{ AutomationAssumeRole.OutputS3BucketName }}"
parameters:
Action: "configure"
AWS.ConfigFile: "/home/ec2-user/.aws/config"
AWS.Profile: "my-profile"
在此示例中,变量InstanceId和AutomationAssumeRole.OutputS3BucketName将通过参数传递给自动化文档以获取正确的值。如果变量仍未解析,则需要通过检查文档和参数配置来查找其他可能的问题。