如何在AWS IAM策略中为多个语句编写单个条件?

时间:2020-01-27 09:51:32

标签: amazon-web-services amazon-iam

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": "ec2:*",
            "Effect": "Allow",
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": "elasticloadbalancing:*",
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": "cloudwatch:*",
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": "autoscaling:*",
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": "s3:*",
            "Resource": "*"
        }
    ]
}

我需要添加政策到期条件:

"Condition": {
    "DateGreaterThan": {
        "aws:CurrentTime": "2020-01-22T12:29:59Z"
    },
    "DateLessThan": {
        "aws:CurrentTime": "2020-11-22T19:35:00Z"
    }
}

1 个答案:

答案 0 :(得分:0)

尝试一下(我没有测试):

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "ec2:*",
                "elasticloadbalancing:*",
                "cloudwatch:*",
                "autoscaling:*",
                "s3:*"
            ]
            "Resource": "*",
            "Condition": {
                "DateGreaterThan": {
                    "aws:CurrentTime": "2020-01-22T12:29:59Z"
                },
                "DateLessThan": {
                    "aws:CurrentTime": "2020-11-22T19:35:00Z"
                }
            }
        }
    ]
}
相关问题