How to access multi line values in yaml #625
Unanswered
roco1234
asked this question in
OPA and Rego
Replies: 1 comment
-
Hi there! The Rego Playground may not support YAML, but providing a more complete example, including the command(s) you run to evaluate this would help. Using just the YAML file you provided for evaluation seems to work fine: p.yaml Resources:
SQSQueuePolicy:
Type: "AWS::SQS::QueuePolicy"
Properties:
Queues:
- "https://sqs.us-east-2.amazonaws.com/444455556666/example-queue"
PolicyDocument:
Fn::Sub: |
{
"Version": "2012-10-17",
"Id": "QueuePolicy",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "*",
"Resource": "arn:aws:sqs:${AWS::Region}:${AWS::AccountId}:example-queue",
"Condition": {
"ArnEquals": {
"aws:SourceArn": "arn:aws:sns:${AWS::Region}:${AWS::AccountId}:example-topic"
}
}
}
]
}
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a cloudformation template that I want to write a rego policy for
Where a multi line operator is used
Fn::Sub: |
, I cannot access the property values. Outputs are:input.PolicyDocument
= ["AWS::Region", "AWS::AccountId", "AWS::Region", "AWS::AccountId"]input.PolicyDocument["Fn::Sub"]
= undefinedIf I use
Fn::Sub:
Outputs are:input.PolicyDocument
={\"Fn::Sub\": {\"Id\": \"QueuePolicy\", \"Statement\": [{\"Action\": \"*\", \"Condition\": {\"ArnEquals\": {\"aws:SourceArn\": \"arn:aws:sns:${AWS::Region}:${AWS::AccountId}:example-topic\"}}, \"Effect\": \"Allow\", \"Principal\": \"*\", \"Resource\": \"arn:aws:sqs:${AWS::Region}:${AWS::AccountId}:example-queue\"}], \"Version\": \"2012-10-17\"}}
input.PolicyDocument["Fn::Sub"]
={\"Id\": \"QueuePolicy\", \"Statement\": [{\"Action\": \"*\", \"Condition\": {\"ArnEquals\": {\"aws:SourceArn\": \"arn:aws:sns:${AWS::Region}:${AWS::AccountId}:example-topic\"}}, \"Effect\": \"Allow\", \"Principal\": \"*\", \"Resource\": \"arn:aws:sqs:${AWS::Region}:${AWS::AccountId}:example-queue\"}], \"Version\": \"2012-10-17\"}
Is there some way to ensure values are not stripped when using a multi line operator in this way?
Sorry I can't create a playground example as there is no yaml option
Beta Was this translation helpful? Give feedback.
All reactions