github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/getBillingServiceAccount.go (about) 1 // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT. 2 // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 4 package aws 5 6 import ( 7 "context" 8 "reflect" 9 10 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 11 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 12 ) 13 14 // Use this data source to get the Account ID of the [AWS Billing and Cost Management Service Account](http://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/billing-getting-started.html#step-2) for the purpose of permitting in S3 bucket policy. 15 // 16 // ## Example Usage 17 // 18 // <!--Start PulumiCodeChooser --> 19 // ```go 20 // package main 21 // 22 // import ( 23 // 24 // "fmt" 25 // 26 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws" 27 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam" 28 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3" 29 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 30 // 31 // ) 32 // func main() { 33 // pulumi.Run(func(ctx *pulumi.Context) error { 34 // main, err := aws.GetBillingServiceAccount(ctx, nil, nil); 35 // if err != nil { 36 // return err 37 // } 38 // billingLogs, err := s3.NewBucketV2(ctx, "billing_logs", &s3.BucketV2Args{ 39 // Bucket: pulumi.String("my-billing-tf-test-bucket"), 40 // }) 41 // if err != nil { 42 // return err 43 // } 44 // _, err = s3.NewBucketAclV2(ctx, "billing_logs_acl", &s3.BucketAclV2Args{ 45 // Bucket: billingLogs.ID(), 46 // Acl: pulumi.String("private"), 47 // }) 48 // if err != nil { 49 // return err 50 // } 51 // allowBillingLogging := pulumi.All(billingLogs.Arn,billingLogs.Arn).ApplyT(func(_args []interface{}) (iam.GetPolicyDocumentResult, error) { 52 // billingLogsArn := _args[0].(string) 53 // billingLogsArn1 := _args[1].(string) 54 // return iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{ 55 // Statements: []iam.GetPolicyDocumentStatement{ 56 // { 57 // Effect: "Allow", 58 // Principals: []iam.GetPolicyDocumentStatementPrincipal{ 59 // { 60 // Type: "AWS", 61 // Identifiers: interface{}{ 62 // main.Arn, 63 // }, 64 // }, 65 // }, 66 // Actions: []string{ 67 // "s3:GetBucketAcl", 68 // "s3:GetBucketPolicy", 69 // }, 70 // Resources: []string{ 71 // billingLogsArn, 72 // }, 73 // }, 74 // { 75 // Effect: "Allow", 76 // Principals: []iam.GetPolicyDocumentStatementPrincipal{ 77 // { 78 // Type: "AWS", 79 // Identifiers: interface{}{ 80 // main.Arn, 81 // }, 82 // }, 83 // }, 84 // Actions: []string{ 85 // "s3:PutObject", 86 // }, 87 // Resources: []string{ 88 // fmt.Sprintf("%v/*", billingLogsArn1), 89 // }, 90 // }, 91 // }, 92 // }, nil), nil 93 // }).(iam.GetPolicyDocumentResultOutput) 94 // _, err = s3.NewBucketPolicy(ctx, "allow_billing_logging", &s3.BucketPolicyArgs{ 95 // Bucket: billingLogs.ID(), 96 // Policy: allowBillingLogging.ApplyT(func(allowBillingLogging iam.GetPolicyDocumentResult) (*string, error) { 97 // return &allowBillingLogging.Json, nil 98 // }).(pulumi.StringPtrOutput), 99 // }) 100 // if err != nil { 101 // return err 102 // } 103 // return nil 104 // }) 105 // } 106 // ``` 107 // <!--End PulumiCodeChooser --> 108 func GetBillingServiceAccount(ctx *pulumi.Context, args *GetBillingServiceAccountArgs, opts ...pulumi.InvokeOption) (*GetBillingServiceAccountResult, error) { 109 opts = internal.PkgInvokeDefaultOpts(opts) 110 var rv GetBillingServiceAccountResult 111 err := ctx.Invoke("aws:index/getBillingServiceAccount:getBillingServiceAccount", args, &rv, opts...) 112 if err != nil { 113 return nil, err 114 } 115 return &rv, nil 116 } 117 118 // A collection of arguments for invoking getBillingServiceAccount. 119 type GetBillingServiceAccountArgs struct { 120 // ID of the AWS billing service account. 121 Id *string `pulumi:"id"` 122 } 123 124 // A collection of values returned by getBillingServiceAccount. 125 type GetBillingServiceAccountResult struct { 126 // ARN of the AWS billing service account. 127 Arn string `pulumi:"arn"` 128 // ID of the AWS billing service account. 129 Id string `pulumi:"id"` 130 } 131 132 func GetBillingServiceAccountOutput(ctx *pulumi.Context, args GetBillingServiceAccountOutputArgs, opts ...pulumi.InvokeOption) GetBillingServiceAccountResultOutput { 133 return pulumi.ToOutputWithContext(context.Background(), args). 134 ApplyT(func(v interface{}) (GetBillingServiceAccountResult, error) { 135 args := v.(GetBillingServiceAccountArgs) 136 r, err := GetBillingServiceAccount(ctx, &args, opts...) 137 var s GetBillingServiceAccountResult 138 if r != nil { 139 s = *r 140 } 141 return s, err 142 }).(GetBillingServiceAccountResultOutput) 143 } 144 145 // A collection of arguments for invoking getBillingServiceAccount. 146 type GetBillingServiceAccountOutputArgs struct { 147 // ID of the AWS billing service account. 148 Id pulumi.StringPtrInput `pulumi:"id"` 149 } 150 151 func (GetBillingServiceAccountOutputArgs) ElementType() reflect.Type { 152 return reflect.TypeOf((*GetBillingServiceAccountArgs)(nil)).Elem() 153 } 154 155 // A collection of values returned by getBillingServiceAccount. 156 type GetBillingServiceAccountResultOutput struct{ *pulumi.OutputState } 157 158 func (GetBillingServiceAccountResultOutput) ElementType() reflect.Type { 159 return reflect.TypeOf((*GetBillingServiceAccountResult)(nil)).Elem() 160 } 161 162 func (o GetBillingServiceAccountResultOutput) ToGetBillingServiceAccountResultOutput() GetBillingServiceAccountResultOutput { 163 return o 164 } 165 166 func (o GetBillingServiceAccountResultOutput) ToGetBillingServiceAccountResultOutputWithContext(ctx context.Context) GetBillingServiceAccountResultOutput { 167 return o 168 } 169 170 // ARN of the AWS billing service account. 171 func (o GetBillingServiceAccountResultOutput) Arn() pulumi.StringOutput { 172 return o.ApplyT(func(v GetBillingServiceAccountResult) string { return v.Arn }).(pulumi.StringOutput) 173 } 174 175 // ID of the AWS billing service account. 176 func (o GetBillingServiceAccountResultOutput) Id() pulumi.StringOutput { 177 return o.ApplyT(func(v GetBillingServiceAccountResult) string { return v.Id }).(pulumi.StringOutput) 178 } 179 180 func init() { 181 pulumi.RegisterOutputType(GetBillingServiceAccountResultOutput{}) 182 }