- Newest
- Most votes
- Most comments
This behavior you're experiencing is indeed a limitation of how pattern variables work with alarm annotations in CloudWatch dashboards.
When you use pattern variables like {{ AccountId }} or {{ Region }} in alarm ARNs within annotations, the dashboard save operation (PutDashboard API call) attempts to validate the ARN structure before applying the variable substitution. Since the placeholders aren't valid ARN components during this validation phase, you get the errors about missing region and data source.
Your workaround is correct - using actual valid values (like "us-east-1") that will be replaced during rendering is the appropriate approach. This allows the dashboard to pass validation during saving while still enabling the dynamic behavior you want during viewing.
For many use cases involving Region switching, you can use property variables instead of pattern variables. However, as you've discovered, when working with ARNs that include Region names or account IDs, pattern variables are necessary - but they must contain syntactically valid values at save time.
The pattern variable is working as designed, but the validation process during saving doesn't recognize the placeholders as valid temporary values, which is why you're experiencing this limitation.
Sources
Creating flexible CloudWatch dashboards with dashboard variables - Amazon CloudWatch
Tutorial: Creating a dashboard that uses a regular expression pattern to switch between AWS Regions - Amazon CloudWatch
answered a year ago
Relevant content
asked a year ago
asked 5 years ago
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated 5 months ago

Is there a possiblity to modify
PutDashboardbehavior to replace values before attempting to validate? (E.g. with variable's defaultValue) In my opinion that would improve user experience a lot, while also improving dashboard json readability