Search code examples
amazon-web-serviceselasticsearchamazon-iamaws-cdkamazon-kinesis-firehose

How to produce "all principals" to principal - "AWS": "*"


When I write the following code:

const somePolicy: PolicyStatement = new PolicyStatement({
      effect: Effect.ALLOW,
      resources: ["someData/*"],
      actions: ["es:*"],
      principals: [
        new ArnPrincipal("*")
      ],
      conditions: {
        IpAddress: {
          SourceIp: ["*"]
        }
      }

    });

I receive following access policy in the Elastic-Domain:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": "*",
      "Action": "es:*",
      "Resource": "someData/*",
      "Condition": {
        "IpAddress": {
          "SourceIp": "*"
        }
      }
    }
  ]
}

My goal is to get this principal:

"Principal": {
        "AWS": "*"
 },

How can I receive this with cdk?

Thanks


Solution

  • "Principal": "*" is same as "Principal": {"AWS": "*"}. So it does not matter how you write it. CDK uses the first option, because there is no reason to make it longer than it needs to be.