How to define a Cost Category with additional logical operators such as NOT and OR besides AND

0

The General AWS Cost Categories FAQs and documentation mention that using the JSON Editor in the Cost Category creation Console, one can

define a Cost Category with additional logical operators such as NOT and OR besides AND

But I can not find any example and my attempts all lead to errors being flagged in the JSON editor. Would love to find some examples of how to specify the OR of several Tags.

The CostCategoryRule says Root level OR isn't supported. We recommend that you create a separate rule instead. But I have no idea how one could create a separate rule that would do what I need.

What I would like to do is the following, but it currently gives me the error Failed to create Cost Category: Expression cannot contain OR on root level:

{
	"RuleVersion": "CostCategoryExpression.v1",
	"Rules": [
		{
			"Type": "REGULAR",
			"Value": "production-001",
			"Rule": {
				"Or": [
					{
						"Tags": {
							"Key": "Environnment",
							"Values": [
								"prod"
							],
							"MatchOptions": [
								"EQUALS"
							]
						}
					},
					{
						"Tags": {
							"Key": "Environment",
							"Values": [
								"prod"
							],
							"MatchOptions": [
								"EQUALS"
							]
						}
					},
					{
						"Tags": {
							"Key": "TerraformWorkspace",
							"Values": [
								"prod"
							],
							"MatchOptions": [
								"CONTAINS"
							]
						}
					},
					{
						"Tags": {
							"Key": "aws:ecs:clusterName",
							"Values": [
								"prod"
							],
							"MatchOptions": [
								"CONTAINS"
							]
						}
					}
				]
			}
		}
	]
}
profile picture
gefragt vor 2 Jahren343 Aufrufe
1 Antwort
0

You can view these documentation: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Expression.html#awscostmanagement-Type-Expression-Not

Uses Expression Syntax: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Expression.html

Example:

{"Not": {"Dimensions": { "Key": "USAGE_TYPE", "Values": ["DataTransfer"] }}}
beantwortet vor 2 Jahren
  • The link to Expression Syntax is helpful, but not to answer my Question. It won't let me use OR at the top level. I will update the question to have more info.

  • Did you get a resolution to this? Having the same issue.

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen