-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
terraform resources for the Cost Explorer Service #16137
Comments
Also interested in this, I could work on the implementation! I'd have a few points to discuss before working on it though:
|
Looks like CloudFormation support for Anomaly Monitor (AWS::CE::AnomalyMonitor) and Anomaly Subscription (AWS::CE::AnomalySubscription) is about to go live. Providing documentation links in case they're helpful in crafting relevant Terraform resources. In case triage team missed it, here's an old request to support Cost Categories (another Cost Explorer service): #12801. |
Here's updated description for this feature request, with focus on Cost Anomaly Detection. DescriptionAWS has announced General Availability of AWS Cost Anomaly Detection on Dec. 16, 2020.
Basically, it's a rare FREE AWS service that can alert users about anomalies in their infrastructure costs, making it an extremely useful service for anyone operating infrastructure on AWS. New or Affected Resource(s)
Potential Terraform ConfigurationSimple example: resource "aws_ce_anomaly_monitor" "service_monitor" {
name = "AWSServiceMonitor"
type = "DIMENSIONAL"
dimension = "SERVICE"
}
resource "aws_ce_anomaly_subscription" "anomaly_subscription" {
name = "DailyAnomalySubscription"
threshold = 100
frequency = "DAILY"
monitor_arn_list = [
aws_ce_anomaly_subscription.anomaly_subscription.arn,
]
subscribers = [
{
type = "EMAIL"
address = "abc@example.com"
}
]
} Complex example: resource "aws_ce_anomaly_monitor" "linked_account_monitor" {
name = "LinkedAccountMonitor"
type = "CUSTOM"
specification = <<JSON
{
"Dimensions": {
"Key": "LINKED_ACCOUNT",
"Values": [
"123456789012",
"123456789013"
]
}
}
JSON
}
resource "aws_sns_topic" "cost_anomaly_updates" {
name = "CostAnomalyUpdates"
}
data "aws_iam_policy_document" "sns_topic_policy" {
policy_id = "__default_policy_ID"
statement {
sid = "AWSAnomalyDetectionSNSPublishingPermissions"
actions = [
"SNS:Publish",
]
effect = "Allow"
principals {
type = "Service"
identifiers = ["costalerts.amazonaws.com"]
}
resources = [
aws_sns_topic.cost_anomaly_updates.arn,
]
}
statement {
sid = "__default_statement_ID"
actions = [
"SNS:Subscribe",
"SNS:SetTopicAttributes",
"SNS:RemovePermission",
"SNS:Receive",
"SNS:Publish",
"SNS:ListSubscriptionsByTopic",
"SNS:GetTopicAttributes",
"SNS:DeleteTopic",
"SNS:AddPermission",
]
condition {
test = "StringEquals"
variable = "AWS:SourceOwner"
values = [
var.account-id,
]
}
effect = "Allow"
principals {
type = "AWS"
identifiers = ["*"]
}
resources = [
aws_sns_topic.cost_anomaly_updates.arn,
]
}
}
resource "aws_sns_topic_policy" "default" {
arn = aws_sns_topic.cost_anomaly_updates.arn
policy = data.aws_iam_policy_document.sns_topic_policy.json
}
resource "aws_ce_anomaly_subscription" "realtime_subscription" {
name = "RealtimeAnomalySubscription"
threshold = 0
frequency = "IMMEDIATE"
monitor_arn_list = [
aws_ce_anomaly_subscription.anomaly_subscription.arn,
]
subscribers = [
{
type = "SNS"
address = aws_sns_topic.cost_anomaly_updates.arn
}
]
depends_on = [
aws_sns_topic_policy.default,
]
} References
|
Any planned date for this. I certainly need this. |
Bump. This would be great, especially since tag based cost anomaly detection is now available. |
Yes, I would love to have this as well. |
Be patient :) I started working on it. |
Related #12801 |
💯 On this. Thanks for getting this rolling. @headincl0ud Is the a projection on what release/date this could arrive? |
Hi all 👋 Just letting you know that this is issue is featured on this quarters roadmap. If a PR exists to close the issue a maintainer will review and either make changes directly, or work with the original author to get the contribution merged. If you have written a PR to resolve the issue please ensure the "Allow edits from maintainers" box is checked. Thanks for your patience and we are looking forward to getting this merged soon! |
Hi folks! #25177 and #25224 have added support for Special thanks to @brittandeyoung for his PRs! 👏🏻 And thank you to everyone in this thread for contributing to the discussion around these resources. If there are any additional resources desired beyond those proposed by this issue: please open a new issue detailing the resource and your potential use case. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Community Note
Description
AWS provides a dedicated set of APIs for managing AWS Cost Explorer.
https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/Welcome.html
I'm finding it would be handy to be able to provision some of those resource using terraform particularly I'm interested in https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_CreateAnomalyMonitor.html
New or Affected Resource(s)
Potential Terraform Configuration
References
The text was updated successfully, but these errors were encountered: