普通网友 2018-12-21 12:36
浏览 88

通过空运行API调用进行AWS IAM策略验证

I am working on a tool which takes IAM policy as JSON and creates the policy on aws. I am using aws-sdk-go for building the tool. I am looking for a way through which I can validate the policy before executing it on aws. Does AWS provide some sort of API to dry-run the policy creation or something like that?

The things I have tried: I am validating the policy field by field.

  • Effect field must be Allow or Deny
  • For Action field, I added a dictionary in my tool which map service to the valid actions. Problem with this approach is it requires a lot of maintenance. AWS keep releasing new services and action and I have to update the dictionary.
  • For a resource, it should be valid ARN.

A couple of other validations are added but its really tough to add all validation checks manually. I believe, aws must be providing some sort of dry-run facility for a policy.

  • 写回答

1条回答 默认 最新

  • dongrong8972 2019-01-06 16:30
    关注

    The AWS API exposes a policy simulator endpoint. You should will functions that make it easy to use the policy simulator at https://docs.aws.amazon.com/sdk-for-go/api/service/iam/ and specifically https://docs.aws.amazon.com/sdk-for-go/api/service/iam/#IAM.SimulateCustomPolicy.

    The policy simulator will allow you to validate the json of your policy, and verify that your intent is expressed in the outcome of the permissions you grant in the policy. You can supply context keys such as aws:SourceIp, aws:RequestedRegion etc.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分