The ARN for an AWS managed policy is going to be arn:aws:iam::aws:policy/
followed by the policy name. There's really no need to look it up using a data
element, since it will always be in that format. So to attach the policy in your example you would use the following:
resource "aws_iam_role_policy_attachment" "CloudWatchAgentServer" {
role = aws_iam_role.CloudWatchAgentServerRole.name
policy_arn = "arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy"
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…