github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/codebuild/resourcePolicy.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 codebuild 5 6 import ( 7 "context" 8 "reflect" 9 10 "errors" 11 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 12 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 13 ) 14 15 // Provides a CodeBuild Resource Policy Resource. 16 // 17 // ## Example Usage 18 // 19 // <!--Start PulumiCodeChooser --> 20 // ```go 21 // package main 22 // 23 // import ( 24 // 25 // "encoding/json" 26 // "fmt" 27 // 28 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws" 29 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/codebuild" 30 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 31 // 32 // ) 33 // 34 // func main() { 35 // pulumi.Run(func(ctx *pulumi.Context) error { 36 // example, err := codebuild.NewReportGroup(ctx, "example", &codebuild.ReportGroupArgs{ 37 // Name: pulumi.String("example"), 38 // Type: pulumi.String("TEST"), 39 // ExportConfig: &codebuild.ReportGroupExportConfigArgs{ 40 // Type: pulumi.String("NO_EXPORT"), 41 // }, 42 // }) 43 // if err != nil { 44 // return err 45 // } 46 // current, err := aws.GetPartition(ctx, nil, nil) 47 // if err != nil { 48 // return err 49 // } 50 // currentGetCallerIdentity, err := aws.GetCallerIdentity(ctx, nil, nil) 51 // if err != nil { 52 // return err 53 // } 54 // _, err = codebuild.NewResourcePolicy(ctx, "example", &codebuild.ResourcePolicyArgs{ 55 // ResourceArn: example.Arn, 56 // Policy: example.Arn.ApplyT(func(arn string) (pulumi.String, error) { 57 // var _zero pulumi.String 58 // tmpJSON0, err := json.Marshal(map[string]interface{}{ 59 // "Version": "2012-10-17", 60 // "Id": "default", 61 // "Statement": []map[string]interface{}{ 62 // map[string]interface{}{ 63 // "Sid": "default", 64 // "Effect": "Allow", 65 // "Principal": map[string]interface{}{ 66 // "AWS": fmt.Sprintf("arn:%v:iam::%v:root", current.Partition, currentGetCallerIdentity.AccountId), 67 // }, 68 // "Action": []string{ 69 // "codebuild:BatchGetReportGroups", 70 // "codebuild:BatchGetReports", 71 // "codebuild:ListReportsForReportGroup", 72 // "codebuild:DescribeTestCases", 73 // }, 74 // "Resource": arn, 75 // }, 76 // }, 77 // }) 78 // if err != nil { 79 // return _zero, err 80 // } 81 // json0 := string(tmpJSON0) 82 // return pulumi.String(json0), nil 83 // }).(pulumi.StringOutput), 84 // }) 85 // if err != nil { 86 // return err 87 // } 88 // return nil 89 // }) 90 // } 91 // 92 // ``` 93 // <!--End PulumiCodeChooser --> 94 // 95 // ## Import 96 // 97 // Using `pulumi import`, import CodeBuild Resource Policy using the CodeBuild Resource Policy arn. For example: 98 // 99 // ```sh 100 // $ pulumi import aws:codebuild/resourcePolicy:ResourcePolicy example arn:aws:codebuild:us-west-2:123456789:report-group/report-group-name 101 // ``` 102 type ResourcePolicy struct { 103 pulumi.CustomResourceState 104 105 // A JSON-formatted resource policy. For more information, see [Sharing a Projec](https://docs.aws.amazon.com/codebuild/latest/userguide/project-sharing.html#project-sharing-share) and [Sharing a Report Group](https://docs.aws.amazon.com/codebuild/latest/userguide/report-groups-sharing.html#report-groups-sharing-share). 106 Policy pulumi.StringOutput `pulumi:"policy"` 107 // The ARN of the Project or ReportGroup resource you want to associate with a resource policy. 108 ResourceArn pulumi.StringOutput `pulumi:"resourceArn"` 109 } 110 111 // NewResourcePolicy registers a new resource with the given unique name, arguments, and options. 112 func NewResourcePolicy(ctx *pulumi.Context, 113 name string, args *ResourcePolicyArgs, opts ...pulumi.ResourceOption) (*ResourcePolicy, error) { 114 if args == nil { 115 return nil, errors.New("missing one or more required arguments") 116 } 117 118 if args.Policy == nil { 119 return nil, errors.New("invalid value for required argument 'Policy'") 120 } 121 if args.ResourceArn == nil { 122 return nil, errors.New("invalid value for required argument 'ResourceArn'") 123 } 124 opts = internal.PkgResourceDefaultOpts(opts) 125 var resource ResourcePolicy 126 err := ctx.RegisterResource("aws:codebuild/resourcePolicy:ResourcePolicy", name, args, &resource, opts...) 127 if err != nil { 128 return nil, err 129 } 130 return &resource, nil 131 } 132 133 // GetResourcePolicy gets an existing ResourcePolicy resource's state with the given name, ID, and optional 134 // state properties that are used to uniquely qualify the lookup (nil if not required). 135 func GetResourcePolicy(ctx *pulumi.Context, 136 name string, id pulumi.IDInput, state *ResourcePolicyState, opts ...pulumi.ResourceOption) (*ResourcePolicy, error) { 137 var resource ResourcePolicy 138 err := ctx.ReadResource("aws:codebuild/resourcePolicy:ResourcePolicy", name, id, state, &resource, opts...) 139 if err != nil { 140 return nil, err 141 } 142 return &resource, nil 143 } 144 145 // Input properties used for looking up and filtering ResourcePolicy resources. 146 type resourcePolicyState struct { 147 // A JSON-formatted resource policy. For more information, see [Sharing a Projec](https://docs.aws.amazon.com/codebuild/latest/userguide/project-sharing.html#project-sharing-share) and [Sharing a Report Group](https://docs.aws.amazon.com/codebuild/latest/userguide/report-groups-sharing.html#report-groups-sharing-share). 148 Policy *string `pulumi:"policy"` 149 // The ARN of the Project or ReportGroup resource you want to associate with a resource policy. 150 ResourceArn *string `pulumi:"resourceArn"` 151 } 152 153 type ResourcePolicyState struct { 154 // A JSON-formatted resource policy. For more information, see [Sharing a Projec](https://docs.aws.amazon.com/codebuild/latest/userguide/project-sharing.html#project-sharing-share) and [Sharing a Report Group](https://docs.aws.amazon.com/codebuild/latest/userguide/report-groups-sharing.html#report-groups-sharing-share). 155 Policy pulumi.StringPtrInput 156 // The ARN of the Project or ReportGroup resource you want to associate with a resource policy. 157 ResourceArn pulumi.StringPtrInput 158 } 159 160 func (ResourcePolicyState) ElementType() reflect.Type { 161 return reflect.TypeOf((*resourcePolicyState)(nil)).Elem() 162 } 163 164 type resourcePolicyArgs struct { 165 // A JSON-formatted resource policy. For more information, see [Sharing a Projec](https://docs.aws.amazon.com/codebuild/latest/userguide/project-sharing.html#project-sharing-share) and [Sharing a Report Group](https://docs.aws.amazon.com/codebuild/latest/userguide/report-groups-sharing.html#report-groups-sharing-share). 166 Policy string `pulumi:"policy"` 167 // The ARN of the Project or ReportGroup resource you want to associate with a resource policy. 168 ResourceArn string `pulumi:"resourceArn"` 169 } 170 171 // The set of arguments for constructing a ResourcePolicy resource. 172 type ResourcePolicyArgs struct { 173 // A JSON-formatted resource policy. For more information, see [Sharing a Projec](https://docs.aws.amazon.com/codebuild/latest/userguide/project-sharing.html#project-sharing-share) and [Sharing a Report Group](https://docs.aws.amazon.com/codebuild/latest/userguide/report-groups-sharing.html#report-groups-sharing-share). 174 Policy pulumi.StringInput 175 // The ARN of the Project or ReportGroup resource you want to associate with a resource policy. 176 ResourceArn pulumi.StringInput 177 } 178 179 func (ResourcePolicyArgs) ElementType() reflect.Type { 180 return reflect.TypeOf((*resourcePolicyArgs)(nil)).Elem() 181 } 182 183 type ResourcePolicyInput interface { 184 pulumi.Input 185 186 ToResourcePolicyOutput() ResourcePolicyOutput 187 ToResourcePolicyOutputWithContext(ctx context.Context) ResourcePolicyOutput 188 } 189 190 func (*ResourcePolicy) ElementType() reflect.Type { 191 return reflect.TypeOf((**ResourcePolicy)(nil)).Elem() 192 } 193 194 func (i *ResourcePolicy) ToResourcePolicyOutput() ResourcePolicyOutput { 195 return i.ToResourcePolicyOutputWithContext(context.Background()) 196 } 197 198 func (i *ResourcePolicy) ToResourcePolicyOutputWithContext(ctx context.Context) ResourcePolicyOutput { 199 return pulumi.ToOutputWithContext(ctx, i).(ResourcePolicyOutput) 200 } 201 202 // ResourcePolicyArrayInput is an input type that accepts ResourcePolicyArray and ResourcePolicyArrayOutput values. 203 // You can construct a concrete instance of `ResourcePolicyArrayInput` via: 204 // 205 // ResourcePolicyArray{ ResourcePolicyArgs{...} } 206 type ResourcePolicyArrayInput interface { 207 pulumi.Input 208 209 ToResourcePolicyArrayOutput() ResourcePolicyArrayOutput 210 ToResourcePolicyArrayOutputWithContext(context.Context) ResourcePolicyArrayOutput 211 } 212 213 type ResourcePolicyArray []ResourcePolicyInput 214 215 func (ResourcePolicyArray) ElementType() reflect.Type { 216 return reflect.TypeOf((*[]*ResourcePolicy)(nil)).Elem() 217 } 218 219 func (i ResourcePolicyArray) ToResourcePolicyArrayOutput() ResourcePolicyArrayOutput { 220 return i.ToResourcePolicyArrayOutputWithContext(context.Background()) 221 } 222 223 func (i ResourcePolicyArray) ToResourcePolicyArrayOutputWithContext(ctx context.Context) ResourcePolicyArrayOutput { 224 return pulumi.ToOutputWithContext(ctx, i).(ResourcePolicyArrayOutput) 225 } 226 227 // ResourcePolicyMapInput is an input type that accepts ResourcePolicyMap and ResourcePolicyMapOutput values. 228 // You can construct a concrete instance of `ResourcePolicyMapInput` via: 229 // 230 // ResourcePolicyMap{ "key": ResourcePolicyArgs{...} } 231 type ResourcePolicyMapInput interface { 232 pulumi.Input 233 234 ToResourcePolicyMapOutput() ResourcePolicyMapOutput 235 ToResourcePolicyMapOutputWithContext(context.Context) ResourcePolicyMapOutput 236 } 237 238 type ResourcePolicyMap map[string]ResourcePolicyInput 239 240 func (ResourcePolicyMap) ElementType() reflect.Type { 241 return reflect.TypeOf((*map[string]*ResourcePolicy)(nil)).Elem() 242 } 243 244 func (i ResourcePolicyMap) ToResourcePolicyMapOutput() ResourcePolicyMapOutput { 245 return i.ToResourcePolicyMapOutputWithContext(context.Background()) 246 } 247 248 func (i ResourcePolicyMap) ToResourcePolicyMapOutputWithContext(ctx context.Context) ResourcePolicyMapOutput { 249 return pulumi.ToOutputWithContext(ctx, i).(ResourcePolicyMapOutput) 250 } 251 252 type ResourcePolicyOutput struct{ *pulumi.OutputState } 253 254 func (ResourcePolicyOutput) ElementType() reflect.Type { 255 return reflect.TypeOf((**ResourcePolicy)(nil)).Elem() 256 } 257 258 func (o ResourcePolicyOutput) ToResourcePolicyOutput() ResourcePolicyOutput { 259 return o 260 } 261 262 func (o ResourcePolicyOutput) ToResourcePolicyOutputWithContext(ctx context.Context) ResourcePolicyOutput { 263 return o 264 } 265 266 // A JSON-formatted resource policy. For more information, see [Sharing a Projec](https://docs.aws.amazon.com/codebuild/latest/userguide/project-sharing.html#project-sharing-share) and [Sharing a Report Group](https://docs.aws.amazon.com/codebuild/latest/userguide/report-groups-sharing.html#report-groups-sharing-share). 267 func (o ResourcePolicyOutput) Policy() pulumi.StringOutput { 268 return o.ApplyT(func(v *ResourcePolicy) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput) 269 } 270 271 // The ARN of the Project or ReportGroup resource you want to associate with a resource policy. 272 func (o ResourcePolicyOutput) ResourceArn() pulumi.StringOutput { 273 return o.ApplyT(func(v *ResourcePolicy) pulumi.StringOutput { return v.ResourceArn }).(pulumi.StringOutput) 274 } 275 276 type ResourcePolicyArrayOutput struct{ *pulumi.OutputState } 277 278 func (ResourcePolicyArrayOutput) ElementType() reflect.Type { 279 return reflect.TypeOf((*[]*ResourcePolicy)(nil)).Elem() 280 } 281 282 func (o ResourcePolicyArrayOutput) ToResourcePolicyArrayOutput() ResourcePolicyArrayOutput { 283 return o 284 } 285 286 func (o ResourcePolicyArrayOutput) ToResourcePolicyArrayOutputWithContext(ctx context.Context) ResourcePolicyArrayOutput { 287 return o 288 } 289 290 func (o ResourcePolicyArrayOutput) Index(i pulumi.IntInput) ResourcePolicyOutput { 291 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ResourcePolicy { 292 return vs[0].([]*ResourcePolicy)[vs[1].(int)] 293 }).(ResourcePolicyOutput) 294 } 295 296 type ResourcePolicyMapOutput struct{ *pulumi.OutputState } 297 298 func (ResourcePolicyMapOutput) ElementType() reflect.Type { 299 return reflect.TypeOf((*map[string]*ResourcePolicy)(nil)).Elem() 300 } 301 302 func (o ResourcePolicyMapOutput) ToResourcePolicyMapOutput() ResourcePolicyMapOutput { 303 return o 304 } 305 306 func (o ResourcePolicyMapOutput) ToResourcePolicyMapOutputWithContext(ctx context.Context) ResourcePolicyMapOutput { 307 return o 308 } 309 310 func (o ResourcePolicyMapOutput) MapIndex(k pulumi.StringInput) ResourcePolicyOutput { 311 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ResourcePolicy { 312 return vs[0].(map[string]*ResourcePolicy)[vs[1].(string)] 313 }).(ResourcePolicyOutput) 314 } 315 316 func init() { 317 pulumi.RegisterInputType(reflect.TypeOf((*ResourcePolicyInput)(nil)).Elem(), &ResourcePolicy{}) 318 pulumi.RegisterInputType(reflect.TypeOf((*ResourcePolicyArrayInput)(nil)).Elem(), ResourcePolicyArray{}) 319 pulumi.RegisterInputType(reflect.TypeOf((*ResourcePolicyMapInput)(nil)).Elem(), ResourcePolicyMap{}) 320 pulumi.RegisterOutputType(ResourcePolicyOutput{}) 321 pulumi.RegisterOutputType(ResourcePolicyArrayOutput{}) 322 pulumi.RegisterOutputType(ResourcePolicyMapOutput{}) 323 }