github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/codebuild/sourceCredential.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 Source Credentials Resource. 16 // 17 // > **NOTE:** [Codebuild only allows a single credential per given server type in a given region](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.GitHubSourceCredentials.html). Therefore, when you define `codebuild.SourceCredential`, `codebuild.Project` resource defined in the same module will use it. 18 // 19 // ## Example Usage 20 // 21 // <!--Start PulumiCodeChooser --> 22 // ```go 23 // package main 24 // 25 // import ( 26 // 27 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/codebuild" 28 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 29 // 30 // ) 31 // 32 // func main() { 33 // pulumi.Run(func(ctx *pulumi.Context) error { 34 // _, err := codebuild.NewSourceCredential(ctx, "example", &codebuild.SourceCredentialArgs{ 35 // AuthType: pulumi.String("PERSONAL_ACCESS_TOKEN"), 36 // ServerType: pulumi.String("GITHUB"), 37 // Token: pulumi.String("example"), 38 // }) 39 // if err != nil { 40 // return err 41 // } 42 // return nil 43 // }) 44 // } 45 // 46 // ``` 47 // <!--End PulumiCodeChooser --> 48 // 49 // ### Bitbucket Server Usage 50 // 51 // <!--Start PulumiCodeChooser --> 52 // ```go 53 // package main 54 // 55 // import ( 56 // 57 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/codebuild" 58 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 59 // 60 // ) 61 // 62 // func main() { 63 // pulumi.Run(func(ctx *pulumi.Context) error { 64 // _, err := codebuild.NewSourceCredential(ctx, "example", &codebuild.SourceCredentialArgs{ 65 // AuthType: pulumi.String("BASIC_AUTH"), 66 // ServerType: pulumi.String("BITBUCKET"), 67 // Token: pulumi.String("example"), 68 // UserName: pulumi.String("test-user"), 69 // }) 70 // if err != nil { 71 // return err 72 // } 73 // return nil 74 // }) 75 // } 76 // 77 // ``` 78 // <!--End PulumiCodeChooser --> 79 // 80 // ## Import 81 // 82 // Using `pulumi import`, import CodeBuild Source Credential using the CodeBuild Source Credential arn. For example: 83 // 84 // ```sh 85 // $ pulumi import aws:codebuild/sourceCredential:SourceCredential example arn:aws:codebuild:us-west-2:123456789:token:github 86 // ``` 87 type SourceCredential struct { 88 pulumi.CustomResourceState 89 90 // The ARN of Source Credential. 91 Arn pulumi.StringOutput `pulumi:"arn"` 92 // The type of authentication used to connect to a GitHub, GitHub Enterprise, or Bitbucket repository. An OAUTH connection is not supported by the API. 93 AuthType pulumi.StringOutput `pulumi:"authType"` 94 // The source provider used for this project. 95 ServerType pulumi.StringOutput `pulumi:"serverType"` 96 // For `GitHub` or `GitHub Enterprise`, this is the personal access token. For `Bitbucket`, this is the app password. 97 Token pulumi.StringOutput `pulumi:"token"` 98 // The Bitbucket username when the authType is `BASIC_AUTH`. This parameter is not valid for other types of source providers or connections. 99 UserName pulumi.StringPtrOutput `pulumi:"userName"` 100 } 101 102 // NewSourceCredential registers a new resource with the given unique name, arguments, and options. 103 func NewSourceCredential(ctx *pulumi.Context, 104 name string, args *SourceCredentialArgs, opts ...pulumi.ResourceOption) (*SourceCredential, error) { 105 if args == nil { 106 return nil, errors.New("missing one or more required arguments") 107 } 108 109 if args.AuthType == nil { 110 return nil, errors.New("invalid value for required argument 'AuthType'") 111 } 112 if args.ServerType == nil { 113 return nil, errors.New("invalid value for required argument 'ServerType'") 114 } 115 if args.Token == nil { 116 return nil, errors.New("invalid value for required argument 'Token'") 117 } 118 if args.Token != nil { 119 args.Token = pulumi.ToSecret(args.Token).(pulumi.StringInput) 120 } 121 secrets := pulumi.AdditionalSecretOutputs([]string{ 122 "token", 123 }) 124 opts = append(opts, secrets) 125 opts = internal.PkgResourceDefaultOpts(opts) 126 var resource SourceCredential 127 err := ctx.RegisterResource("aws:codebuild/sourceCredential:SourceCredential", name, args, &resource, opts...) 128 if err != nil { 129 return nil, err 130 } 131 return &resource, nil 132 } 133 134 // GetSourceCredential gets an existing SourceCredential resource's state with the given name, ID, and optional 135 // state properties that are used to uniquely qualify the lookup (nil if not required). 136 func GetSourceCredential(ctx *pulumi.Context, 137 name string, id pulumi.IDInput, state *SourceCredentialState, opts ...pulumi.ResourceOption) (*SourceCredential, error) { 138 var resource SourceCredential 139 err := ctx.ReadResource("aws:codebuild/sourceCredential:SourceCredential", name, id, state, &resource, opts...) 140 if err != nil { 141 return nil, err 142 } 143 return &resource, nil 144 } 145 146 // Input properties used for looking up and filtering SourceCredential resources. 147 type sourceCredentialState struct { 148 // The ARN of Source Credential. 149 Arn *string `pulumi:"arn"` 150 // The type of authentication used to connect to a GitHub, GitHub Enterprise, or Bitbucket repository. An OAUTH connection is not supported by the API. 151 AuthType *string `pulumi:"authType"` 152 // The source provider used for this project. 153 ServerType *string `pulumi:"serverType"` 154 // For `GitHub` or `GitHub Enterprise`, this is the personal access token. For `Bitbucket`, this is the app password. 155 Token *string `pulumi:"token"` 156 // The Bitbucket username when the authType is `BASIC_AUTH`. This parameter is not valid for other types of source providers or connections. 157 UserName *string `pulumi:"userName"` 158 } 159 160 type SourceCredentialState struct { 161 // The ARN of Source Credential. 162 Arn pulumi.StringPtrInput 163 // The type of authentication used to connect to a GitHub, GitHub Enterprise, or Bitbucket repository. An OAUTH connection is not supported by the API. 164 AuthType pulumi.StringPtrInput 165 // The source provider used for this project. 166 ServerType pulumi.StringPtrInput 167 // For `GitHub` or `GitHub Enterprise`, this is the personal access token. For `Bitbucket`, this is the app password. 168 Token pulumi.StringPtrInput 169 // The Bitbucket username when the authType is `BASIC_AUTH`. This parameter is not valid for other types of source providers or connections. 170 UserName pulumi.StringPtrInput 171 } 172 173 func (SourceCredentialState) ElementType() reflect.Type { 174 return reflect.TypeOf((*sourceCredentialState)(nil)).Elem() 175 } 176 177 type sourceCredentialArgs struct { 178 // The type of authentication used to connect to a GitHub, GitHub Enterprise, or Bitbucket repository. An OAUTH connection is not supported by the API. 179 AuthType string `pulumi:"authType"` 180 // The source provider used for this project. 181 ServerType string `pulumi:"serverType"` 182 // For `GitHub` or `GitHub Enterprise`, this is the personal access token. For `Bitbucket`, this is the app password. 183 Token string `pulumi:"token"` 184 // The Bitbucket username when the authType is `BASIC_AUTH`. This parameter is not valid for other types of source providers or connections. 185 UserName *string `pulumi:"userName"` 186 } 187 188 // The set of arguments for constructing a SourceCredential resource. 189 type SourceCredentialArgs struct { 190 // The type of authentication used to connect to a GitHub, GitHub Enterprise, or Bitbucket repository. An OAUTH connection is not supported by the API. 191 AuthType pulumi.StringInput 192 // The source provider used for this project. 193 ServerType pulumi.StringInput 194 // For `GitHub` or `GitHub Enterprise`, this is the personal access token. For `Bitbucket`, this is the app password. 195 Token pulumi.StringInput 196 // The Bitbucket username when the authType is `BASIC_AUTH`. This parameter is not valid for other types of source providers or connections. 197 UserName pulumi.StringPtrInput 198 } 199 200 func (SourceCredentialArgs) ElementType() reflect.Type { 201 return reflect.TypeOf((*sourceCredentialArgs)(nil)).Elem() 202 } 203 204 type SourceCredentialInput interface { 205 pulumi.Input 206 207 ToSourceCredentialOutput() SourceCredentialOutput 208 ToSourceCredentialOutputWithContext(ctx context.Context) SourceCredentialOutput 209 } 210 211 func (*SourceCredential) ElementType() reflect.Type { 212 return reflect.TypeOf((**SourceCredential)(nil)).Elem() 213 } 214 215 func (i *SourceCredential) ToSourceCredentialOutput() SourceCredentialOutput { 216 return i.ToSourceCredentialOutputWithContext(context.Background()) 217 } 218 219 func (i *SourceCredential) ToSourceCredentialOutputWithContext(ctx context.Context) SourceCredentialOutput { 220 return pulumi.ToOutputWithContext(ctx, i).(SourceCredentialOutput) 221 } 222 223 // SourceCredentialArrayInput is an input type that accepts SourceCredentialArray and SourceCredentialArrayOutput values. 224 // You can construct a concrete instance of `SourceCredentialArrayInput` via: 225 // 226 // SourceCredentialArray{ SourceCredentialArgs{...} } 227 type SourceCredentialArrayInput interface { 228 pulumi.Input 229 230 ToSourceCredentialArrayOutput() SourceCredentialArrayOutput 231 ToSourceCredentialArrayOutputWithContext(context.Context) SourceCredentialArrayOutput 232 } 233 234 type SourceCredentialArray []SourceCredentialInput 235 236 func (SourceCredentialArray) ElementType() reflect.Type { 237 return reflect.TypeOf((*[]*SourceCredential)(nil)).Elem() 238 } 239 240 func (i SourceCredentialArray) ToSourceCredentialArrayOutput() SourceCredentialArrayOutput { 241 return i.ToSourceCredentialArrayOutputWithContext(context.Background()) 242 } 243 244 func (i SourceCredentialArray) ToSourceCredentialArrayOutputWithContext(ctx context.Context) SourceCredentialArrayOutput { 245 return pulumi.ToOutputWithContext(ctx, i).(SourceCredentialArrayOutput) 246 } 247 248 // SourceCredentialMapInput is an input type that accepts SourceCredentialMap and SourceCredentialMapOutput values. 249 // You can construct a concrete instance of `SourceCredentialMapInput` via: 250 // 251 // SourceCredentialMap{ "key": SourceCredentialArgs{...} } 252 type SourceCredentialMapInput interface { 253 pulumi.Input 254 255 ToSourceCredentialMapOutput() SourceCredentialMapOutput 256 ToSourceCredentialMapOutputWithContext(context.Context) SourceCredentialMapOutput 257 } 258 259 type SourceCredentialMap map[string]SourceCredentialInput 260 261 func (SourceCredentialMap) ElementType() reflect.Type { 262 return reflect.TypeOf((*map[string]*SourceCredential)(nil)).Elem() 263 } 264 265 func (i SourceCredentialMap) ToSourceCredentialMapOutput() SourceCredentialMapOutput { 266 return i.ToSourceCredentialMapOutputWithContext(context.Background()) 267 } 268 269 func (i SourceCredentialMap) ToSourceCredentialMapOutputWithContext(ctx context.Context) SourceCredentialMapOutput { 270 return pulumi.ToOutputWithContext(ctx, i).(SourceCredentialMapOutput) 271 } 272 273 type SourceCredentialOutput struct{ *pulumi.OutputState } 274 275 func (SourceCredentialOutput) ElementType() reflect.Type { 276 return reflect.TypeOf((**SourceCredential)(nil)).Elem() 277 } 278 279 func (o SourceCredentialOutput) ToSourceCredentialOutput() SourceCredentialOutput { 280 return o 281 } 282 283 func (o SourceCredentialOutput) ToSourceCredentialOutputWithContext(ctx context.Context) SourceCredentialOutput { 284 return o 285 } 286 287 // The ARN of Source Credential. 288 func (o SourceCredentialOutput) Arn() pulumi.StringOutput { 289 return o.ApplyT(func(v *SourceCredential) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput) 290 } 291 292 // The type of authentication used to connect to a GitHub, GitHub Enterprise, or Bitbucket repository. An OAUTH connection is not supported by the API. 293 func (o SourceCredentialOutput) AuthType() pulumi.StringOutput { 294 return o.ApplyT(func(v *SourceCredential) pulumi.StringOutput { return v.AuthType }).(pulumi.StringOutput) 295 } 296 297 // The source provider used for this project. 298 func (o SourceCredentialOutput) ServerType() pulumi.StringOutput { 299 return o.ApplyT(func(v *SourceCredential) pulumi.StringOutput { return v.ServerType }).(pulumi.StringOutput) 300 } 301 302 // For `GitHub` or `GitHub Enterprise`, this is the personal access token. For `Bitbucket`, this is the app password. 303 func (o SourceCredentialOutput) Token() pulumi.StringOutput { 304 return o.ApplyT(func(v *SourceCredential) pulumi.StringOutput { return v.Token }).(pulumi.StringOutput) 305 } 306 307 // The Bitbucket username when the authType is `BASIC_AUTH`. This parameter is not valid for other types of source providers or connections. 308 func (o SourceCredentialOutput) UserName() pulumi.StringPtrOutput { 309 return o.ApplyT(func(v *SourceCredential) pulumi.StringPtrOutput { return v.UserName }).(pulumi.StringPtrOutput) 310 } 311 312 type SourceCredentialArrayOutput struct{ *pulumi.OutputState } 313 314 func (SourceCredentialArrayOutput) ElementType() reflect.Type { 315 return reflect.TypeOf((*[]*SourceCredential)(nil)).Elem() 316 } 317 318 func (o SourceCredentialArrayOutput) ToSourceCredentialArrayOutput() SourceCredentialArrayOutput { 319 return o 320 } 321 322 func (o SourceCredentialArrayOutput) ToSourceCredentialArrayOutputWithContext(ctx context.Context) SourceCredentialArrayOutput { 323 return o 324 } 325 326 func (o SourceCredentialArrayOutput) Index(i pulumi.IntInput) SourceCredentialOutput { 327 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *SourceCredential { 328 return vs[0].([]*SourceCredential)[vs[1].(int)] 329 }).(SourceCredentialOutput) 330 } 331 332 type SourceCredentialMapOutput struct{ *pulumi.OutputState } 333 334 func (SourceCredentialMapOutput) ElementType() reflect.Type { 335 return reflect.TypeOf((*map[string]*SourceCredential)(nil)).Elem() 336 } 337 338 func (o SourceCredentialMapOutput) ToSourceCredentialMapOutput() SourceCredentialMapOutput { 339 return o 340 } 341 342 func (o SourceCredentialMapOutput) ToSourceCredentialMapOutputWithContext(ctx context.Context) SourceCredentialMapOutput { 343 return o 344 } 345 346 func (o SourceCredentialMapOutput) MapIndex(k pulumi.StringInput) SourceCredentialOutput { 347 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *SourceCredential { 348 return vs[0].(map[string]*SourceCredential)[vs[1].(string)] 349 }).(SourceCredentialOutput) 350 } 351 352 func init() { 353 pulumi.RegisterInputType(reflect.TypeOf((*SourceCredentialInput)(nil)).Elem(), &SourceCredential{}) 354 pulumi.RegisterInputType(reflect.TypeOf((*SourceCredentialArrayInput)(nil)).Elem(), SourceCredentialArray{}) 355 pulumi.RegisterInputType(reflect.TypeOf((*SourceCredentialMapInput)(nil)).Elem(), SourceCredentialMap{}) 356 pulumi.RegisterOutputType(SourceCredentialOutput{}) 357 pulumi.RegisterOutputType(SourceCredentialArrayOutput{}) 358 pulumi.RegisterOutputType(SourceCredentialMapOutput{}) 359 }