@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
178 lines • 7.88 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.BudgetAction = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Provides a budget action resource. Budget actions are cost savings controls that run either automatically on your behalf or by using a workflow approval process.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = aws.iam.getPolicyDocument({
* statements: [{
* effect: "Allow",
* actions: ["ec2:Describe*"],
* resources: ["*"],
* }],
* });
* const examplePolicy = new aws.iam.Policy("example", {
* name: "example",
* description: "My example policy",
* policy: example.then(example => example.json),
* });
* const current = aws.getPartition({});
* const assumeRole = current.then(current => aws.iam.getPolicyDocument({
* statements: [{
* effect: "Allow",
* principals: [{
* type: "Service",
* identifiers: [`budgets.${current.dnsSuffix}`],
* }],
* actions: ["sts:AssumeRole"],
* }],
* }));
* const exampleRole = new aws.iam.Role("example", {
* name: "example",
* assumeRolePolicy: assumeRole.then(assumeRole => assumeRole.json),
* });
* const exampleBudget = new aws.budgets.Budget("example", {
* name: "example",
* budgetType: "USAGE",
* limitAmount: "10.0",
* limitUnit: "dollars",
* timePeriodStart: "2006-01-02_15:04",
* timeUnit: "MONTHLY",
* });
* const exampleBudgetAction = new aws.budgets.BudgetAction("example", {
* budgetName: exampleBudget.name,
* actionType: "APPLY_IAM_POLICY",
* approvalModel: "AUTOMATIC",
* notificationType: "ACTUAL",
* executionRoleArn: exampleRole.arn,
* actionThreshold: {
* actionThresholdType: "ABSOLUTE_VALUE",
* actionThresholdValue: 100,
* },
* definition: {
* iamActionDefinition: {
* policyArn: examplePolicy.arn,
* roles: [exampleRole.name],
* },
* },
* subscribers: [{
* address: "example@example.example",
* subscriptionType: "EMAIL",
* }],
* tags: {
* Tag1: "Value1",
* Tag2: "Value2",
* },
* });
* ```
*
* ## Import
*
* Using `pulumi import`, import budget actions using `AccountID:ActionID:BudgetName`. For example:
*
* ```sh
* $ pulumi import aws:budgets/budgetAction:BudgetAction myBudget 123456789012:some-id:myBudget
* ```
*/
class BudgetAction extends pulumi.CustomResource {
/**
* Get an existing BudgetAction resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new BudgetAction(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of BudgetAction. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === BudgetAction.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["accountId"] = state ? state.accountId : undefined;
resourceInputs["actionId"] = state ? state.actionId : undefined;
resourceInputs["actionThreshold"] = state ? state.actionThreshold : undefined;
resourceInputs["actionType"] = state ? state.actionType : undefined;
resourceInputs["approvalModel"] = state ? state.approvalModel : undefined;
resourceInputs["arn"] = state ? state.arn : undefined;
resourceInputs["budgetName"] = state ? state.budgetName : undefined;
resourceInputs["definition"] = state ? state.definition : undefined;
resourceInputs["executionRoleArn"] = state ? state.executionRoleArn : undefined;
resourceInputs["notificationType"] = state ? state.notificationType : undefined;
resourceInputs["status"] = state ? state.status : undefined;
resourceInputs["subscribers"] = state ? state.subscribers : undefined;
resourceInputs["tags"] = state ? state.tags : undefined;
resourceInputs["tagsAll"] = state ? state.tagsAll : undefined;
}
else {
const args = argsOrState;
if ((!args || args.actionThreshold === undefined) && !opts.urn) {
throw new Error("Missing required property 'actionThreshold'");
}
if ((!args || args.actionType === undefined) && !opts.urn) {
throw new Error("Missing required property 'actionType'");
}
if ((!args || args.approvalModel === undefined) && !opts.urn) {
throw new Error("Missing required property 'approvalModel'");
}
if ((!args || args.budgetName === undefined) && !opts.urn) {
throw new Error("Missing required property 'budgetName'");
}
if ((!args || args.definition === undefined) && !opts.urn) {
throw new Error("Missing required property 'definition'");
}
if ((!args || args.executionRoleArn === undefined) && !opts.urn) {
throw new Error("Missing required property 'executionRoleArn'");
}
if ((!args || args.notificationType === undefined) && !opts.urn) {
throw new Error("Missing required property 'notificationType'");
}
if ((!args || args.subscribers === undefined) && !opts.urn) {
throw new Error("Missing required property 'subscribers'");
}
resourceInputs["accountId"] = args ? args.accountId : undefined;
resourceInputs["actionThreshold"] = args ? args.actionThreshold : undefined;
resourceInputs["actionType"] = args ? args.actionType : undefined;
resourceInputs["approvalModel"] = args ? args.approvalModel : undefined;
resourceInputs["budgetName"] = args ? args.budgetName : undefined;
resourceInputs["definition"] = args ? args.definition : undefined;
resourceInputs["executionRoleArn"] = args ? args.executionRoleArn : undefined;
resourceInputs["notificationType"] = args ? args.notificationType : undefined;
resourceInputs["subscribers"] = args ? args.subscribers : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
resourceInputs["actionId"] = undefined /*out*/;
resourceInputs["arn"] = undefined /*out*/;
resourceInputs["status"] = undefined /*out*/;
resourceInputs["tagsAll"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(BudgetAction.__pulumiType, name, resourceInputs, opts);
}
}
exports.BudgetAction = BudgetAction;
/** @internal */
BudgetAction.__pulumiType = 'aws:budgets/budgetAction:BudgetAction';
//# sourceMappingURL=budgetAction.js.map