-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9092 from mozamimy/cost-filter-multiple-values
Support multiple values per one cost filter in aws_budgets_budget resource
- Loading branch information
Showing
13 changed files
with
1,093 additions
and
853 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
```release-note:enhancement | ||
resource/aws_budgets_budget: Add the `cost_filter` argument which allows multiple `values` to be specified per filter. This new argument will eventually replace the `cost_filters` argument | ||
``` | ||
|
||
```release-note:enhancement | ||
resource/aws_budgets_budget: Change `time_period_start` to an optional argument. If you don't specify a start date, AWS defaults to the start of your chosen time period | ||
``` | ||
|
||
```release-note:bug | ||
resource/aws_budgets_budget: Change the service name in the `arn` attribute from `budgetservice` to `budgets` | ||
``` | ||
|
||
```release-note:bug | ||
resource/aws_budgets_budget: Suppress plan differences with trailing zeroes for `limit_amount` | ||
``` | ||
|
||
```release-note:bug | ||
resource/aws_budgets_budget_action: Change the service name in the `arn` attribute from `budgetservice` to `budgets` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,44 @@ | ||
package glue | ||
package budgets | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
func DecodeBudgetsBudgetActionID(id string) (string, string, string, error) { | ||
parts := strings.Split(id, ":") | ||
if len(parts) != 3 { | ||
return "", "", "", fmt.Errorf("Unexpected format of ID (%q), expected AccountID:ActionID:BudgetName", id) | ||
const budgetActionResourceIDSeparator = ":" | ||
|
||
func BudgetActionCreateResourceID(accountID, actionID, budgetName string) string { | ||
parts := []string{accountID, actionID, budgetName} | ||
id := strings.Join(parts, budgetActionResourceIDSeparator) | ||
|
||
return id | ||
} | ||
|
||
func BudgetActionParseResourceID(id string) (string, string, string, error) { | ||
parts := strings.Split(id, budgetActionResourceIDSeparator) | ||
|
||
if len(parts) == 3 && parts[0] != "" && parts[1] != "" && parts[2] != "" { | ||
return parts[0], parts[1], parts[2], nil | ||
} | ||
return parts[0], parts[1], parts[2], nil | ||
|
||
return "", "", "", fmt.Errorf("unexpected format for ID (%[1]s), expected AccountID%[2]sActionID%[2]sBudgetName", id, budgetActionResourceIDSeparator) | ||
} | ||
|
||
const budgetResourceIDSeparator = ":" | ||
|
||
func BudgetCreateResourceID(accountID, budgetName string) string { | ||
parts := []string{accountID, budgetName} | ||
id := strings.Join(parts, budgetResourceIDSeparator) | ||
|
||
return id | ||
} | ||
|
||
func BudgetParseResourceID(id string) (string, string, error) { | ||
parts := strings.Split(id, budgetResourceIDSeparator) | ||
|
||
if len(parts) == 2 && parts[0] != "" && parts[1] != "" { | ||
return parts[0], parts[1], nil | ||
} | ||
|
||
return "", "", fmt.Errorf("unexpected format for ID (%[1]s), expected AccountID%[2]sBudgetName", id, budgetActionResourceIDSeparator) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package budgets | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
) | ||
|
||
const ( | ||
timePeriodLayout = "2006-01-02_15:04" | ||
) | ||
|
||
func TimePeriodTimestampFromString(s string) (*time.Time, error) { | ||
if s == "" { | ||
return nil, nil | ||
} | ||
|
||
ts, err := time.Parse(timePeriodLayout, s) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return aws.Time(ts), nil | ||
} | ||
|
||
func TimePeriodTimestampToString(ts *time.Time) string { | ||
if ts == nil { | ||
return "" | ||
} | ||
|
||
return aws.TimeValue(ts).Format(timePeriodLayout) | ||
} | ||
|
||
func ValidateTimePeriodTimestamp(v interface{}, k string) (ws []string, errors []error) { | ||
_, err := time.Parse(timePeriodLayout, v.(string)) | ||
|
||
if err != nil { | ||
errors = append(errors, fmt.Errorf("%q cannot be parsed as %q: %w", k, timePeriodLayout, err)) | ||
} | ||
|
||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.