github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/acmpca/policy.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 acmpca 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 // Attaches a resource based policy to a private CA. 16 // 17 // ## Example Usage 18 // 19 // ### Basic 20 // 21 // <!--Start PulumiCodeChooser --> 22 // ```go 23 // package main 24 // 25 // import ( 26 // 27 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/acmpca" 28 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam" 29 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 30 // 31 // ) 32 // func main() { 33 // pulumi.Run(func(ctx *pulumi.Context) error { 34 // example, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{ 35 // Statements: []iam.GetPolicyDocumentStatement{ 36 // { 37 // Sid: pulumi.StringRef("1"), 38 // Effect: pulumi.StringRef("Allow"), 39 // Principals: []iam.GetPolicyDocumentStatementPrincipal{ 40 // { 41 // Type: "AWS", 42 // Identifiers: interface{}{ 43 // current.AccountId, 44 // }, 45 // }, 46 // }, 47 // Actions: []string{ 48 // "acm-pca:DescribeCertificateAuthority", 49 // "acm-pca:GetCertificate", 50 // "acm-pca:GetCertificateAuthorityCertificate", 51 // "acm-pca:ListPermissions", 52 // "acm-pca:ListTags", 53 // }, 54 // Resources: interface{}{ 55 // exampleAwsAcmpcaCertificateAuthority.Arn, 56 // }, 57 // }, 58 // { 59 // Sid: pulumi.StringRef("2"), 60 // Effect: pulumi.StringRef(allow), 61 // Principals: []iam.GetPolicyDocumentStatementPrincipal{ 62 // { 63 // Type: "AWS", 64 // Identifiers: interface{}{ 65 // current.AccountId, 66 // }, 67 // }, 68 // }, 69 // Actions: []string{ 70 // "acm-pca:IssueCertificate", 71 // }, 72 // Resources: interface{}{ 73 // exampleAwsAcmpcaCertificateAuthority.Arn, 74 // }, 75 // Conditions: []iam.GetPolicyDocumentStatementCondition{ 76 // { 77 // Test: "StringEquals", 78 // Variable: "acm-pca:TemplateArn", 79 // Values: []string{ 80 // "arn:aws:acm-pca:::template/EndEntityCertificate/V1", 81 // }, 82 // }, 83 // }, 84 // }, 85 // }, 86 // }, nil); 87 // if err != nil { 88 // return err 89 // } 90 // _, err = acmpca.NewPolicy(ctx, "example", &acmpca.PolicyArgs{ 91 // ResourceArn: pulumi.Any(exampleAwsAcmpcaCertificateAuthority.Arn), 92 // Policy: pulumi.String(example.Json), 93 // }) 94 // if err != nil { 95 // return err 96 // } 97 // return nil 98 // }) 99 // } 100 // ``` 101 // <!--End PulumiCodeChooser --> 102 // 103 // ## Import 104 // 105 // Using `pulumi import`, import `aws_acmpca_policy` using the `resource_arn` value. For example: 106 // 107 // ```sh 108 // $ pulumi import aws:acmpca/policy:Policy example arn:aws:acm-pca:us-east-1:123456789012:certificate-authority/12345678-1234-1234-1234-123456789012 109 // ``` 110 type Policy struct { 111 pulumi.CustomResourceState 112 113 // JSON-formatted IAM policy to attach to the specified private CA resource. 114 Policy pulumi.StringOutput `pulumi:"policy"` 115 // ARN of the private CA to associate with the policy. 116 ResourceArn pulumi.StringOutput `pulumi:"resourceArn"` 117 } 118 119 // NewPolicy registers a new resource with the given unique name, arguments, and options. 120 func NewPolicy(ctx *pulumi.Context, 121 name string, args *PolicyArgs, opts ...pulumi.ResourceOption) (*Policy, error) { 122 if args == nil { 123 return nil, errors.New("missing one or more required arguments") 124 } 125 126 if args.Policy == nil { 127 return nil, errors.New("invalid value for required argument 'Policy'") 128 } 129 if args.ResourceArn == nil { 130 return nil, errors.New("invalid value for required argument 'ResourceArn'") 131 } 132 opts = internal.PkgResourceDefaultOpts(opts) 133 var resource Policy 134 err := ctx.RegisterResource("aws:acmpca/policy:Policy", name, args, &resource, opts...) 135 if err != nil { 136 return nil, err 137 } 138 return &resource, nil 139 } 140 141 // GetPolicy gets an existing Policy resource's state with the given name, ID, and optional 142 // state properties that are used to uniquely qualify the lookup (nil if not required). 143 func GetPolicy(ctx *pulumi.Context, 144 name string, id pulumi.IDInput, state *PolicyState, opts ...pulumi.ResourceOption) (*Policy, error) { 145 var resource Policy 146 err := ctx.ReadResource("aws:acmpca/policy:Policy", name, id, state, &resource, opts...) 147 if err != nil { 148 return nil, err 149 } 150 return &resource, nil 151 } 152 153 // Input properties used for looking up and filtering Policy resources. 154 type policyState struct { 155 // JSON-formatted IAM policy to attach to the specified private CA resource. 156 Policy *string `pulumi:"policy"` 157 // ARN of the private CA to associate with the policy. 158 ResourceArn *string `pulumi:"resourceArn"` 159 } 160 161 type PolicyState struct { 162 // JSON-formatted IAM policy to attach to the specified private CA resource. 163 Policy pulumi.StringPtrInput 164 // ARN of the private CA to associate with the policy. 165 ResourceArn pulumi.StringPtrInput 166 } 167 168 func (PolicyState) ElementType() reflect.Type { 169 return reflect.TypeOf((*policyState)(nil)).Elem() 170 } 171 172 type policyArgs struct { 173 // JSON-formatted IAM policy to attach to the specified private CA resource. 174 Policy string `pulumi:"policy"` 175 // ARN of the private CA to associate with the policy. 176 ResourceArn string `pulumi:"resourceArn"` 177 } 178 179 // The set of arguments for constructing a Policy resource. 180 type PolicyArgs struct { 181 // JSON-formatted IAM policy to attach to the specified private CA resource. 182 Policy pulumi.StringInput 183 // ARN of the private CA to associate with the policy. 184 ResourceArn pulumi.StringInput 185 } 186 187 func (PolicyArgs) ElementType() reflect.Type { 188 return reflect.TypeOf((*policyArgs)(nil)).Elem() 189 } 190 191 type PolicyInput interface { 192 pulumi.Input 193 194 ToPolicyOutput() PolicyOutput 195 ToPolicyOutputWithContext(ctx context.Context) PolicyOutput 196 } 197 198 func (*Policy) ElementType() reflect.Type { 199 return reflect.TypeOf((**Policy)(nil)).Elem() 200 } 201 202 func (i *Policy) ToPolicyOutput() PolicyOutput { 203 return i.ToPolicyOutputWithContext(context.Background()) 204 } 205 206 func (i *Policy) ToPolicyOutputWithContext(ctx context.Context) PolicyOutput { 207 return pulumi.ToOutputWithContext(ctx, i).(PolicyOutput) 208 } 209 210 // PolicyArrayInput is an input type that accepts PolicyArray and PolicyArrayOutput values. 211 // You can construct a concrete instance of `PolicyArrayInput` via: 212 // 213 // PolicyArray{ PolicyArgs{...} } 214 type PolicyArrayInput interface { 215 pulumi.Input 216 217 ToPolicyArrayOutput() PolicyArrayOutput 218 ToPolicyArrayOutputWithContext(context.Context) PolicyArrayOutput 219 } 220 221 type PolicyArray []PolicyInput 222 223 func (PolicyArray) ElementType() reflect.Type { 224 return reflect.TypeOf((*[]*Policy)(nil)).Elem() 225 } 226 227 func (i PolicyArray) ToPolicyArrayOutput() PolicyArrayOutput { 228 return i.ToPolicyArrayOutputWithContext(context.Background()) 229 } 230 231 func (i PolicyArray) ToPolicyArrayOutputWithContext(ctx context.Context) PolicyArrayOutput { 232 return pulumi.ToOutputWithContext(ctx, i).(PolicyArrayOutput) 233 } 234 235 // PolicyMapInput is an input type that accepts PolicyMap and PolicyMapOutput values. 236 // You can construct a concrete instance of `PolicyMapInput` via: 237 // 238 // PolicyMap{ "key": PolicyArgs{...} } 239 type PolicyMapInput interface { 240 pulumi.Input 241 242 ToPolicyMapOutput() PolicyMapOutput 243 ToPolicyMapOutputWithContext(context.Context) PolicyMapOutput 244 } 245 246 type PolicyMap map[string]PolicyInput 247 248 func (PolicyMap) ElementType() reflect.Type { 249 return reflect.TypeOf((*map[string]*Policy)(nil)).Elem() 250 } 251 252 func (i PolicyMap) ToPolicyMapOutput() PolicyMapOutput { 253 return i.ToPolicyMapOutputWithContext(context.Background()) 254 } 255 256 func (i PolicyMap) ToPolicyMapOutputWithContext(ctx context.Context) PolicyMapOutput { 257 return pulumi.ToOutputWithContext(ctx, i).(PolicyMapOutput) 258 } 259 260 type PolicyOutput struct{ *pulumi.OutputState } 261 262 func (PolicyOutput) ElementType() reflect.Type { 263 return reflect.TypeOf((**Policy)(nil)).Elem() 264 } 265 266 func (o PolicyOutput) ToPolicyOutput() PolicyOutput { 267 return o 268 } 269 270 func (o PolicyOutput) ToPolicyOutputWithContext(ctx context.Context) PolicyOutput { 271 return o 272 } 273 274 // JSON-formatted IAM policy to attach to the specified private CA resource. 275 func (o PolicyOutput) Policy() pulumi.StringOutput { 276 return o.ApplyT(func(v *Policy) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput) 277 } 278 279 // ARN of the private CA to associate with the policy. 280 func (o PolicyOutput) ResourceArn() pulumi.StringOutput { 281 return o.ApplyT(func(v *Policy) pulumi.StringOutput { return v.ResourceArn }).(pulumi.StringOutput) 282 } 283 284 type PolicyArrayOutput struct{ *pulumi.OutputState } 285 286 func (PolicyArrayOutput) ElementType() reflect.Type { 287 return reflect.TypeOf((*[]*Policy)(nil)).Elem() 288 } 289 290 func (o PolicyArrayOutput) ToPolicyArrayOutput() PolicyArrayOutput { 291 return o 292 } 293 294 func (o PolicyArrayOutput) ToPolicyArrayOutputWithContext(ctx context.Context) PolicyArrayOutput { 295 return o 296 } 297 298 func (o PolicyArrayOutput) Index(i pulumi.IntInput) PolicyOutput { 299 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Policy { 300 return vs[0].([]*Policy)[vs[1].(int)] 301 }).(PolicyOutput) 302 } 303 304 type PolicyMapOutput struct{ *pulumi.OutputState } 305 306 func (PolicyMapOutput) ElementType() reflect.Type { 307 return reflect.TypeOf((*map[string]*Policy)(nil)).Elem() 308 } 309 310 func (o PolicyMapOutput) ToPolicyMapOutput() PolicyMapOutput { 311 return o 312 } 313 314 func (o PolicyMapOutput) ToPolicyMapOutputWithContext(ctx context.Context) PolicyMapOutput { 315 return o 316 } 317 318 func (o PolicyMapOutput) MapIndex(k pulumi.StringInput) PolicyOutput { 319 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Policy { 320 return vs[0].(map[string]*Policy)[vs[1].(string)] 321 }).(PolicyOutput) 322 } 323 324 func init() { 325 pulumi.RegisterInputType(reflect.TypeOf((*PolicyInput)(nil)).Elem(), &Policy{}) 326 pulumi.RegisterInputType(reflect.TypeOf((*PolicyArrayInput)(nil)).Elem(), PolicyArray{}) 327 pulumi.RegisterInputType(reflect.TypeOf((*PolicyMapInput)(nil)).Elem(), PolicyMap{}) 328 pulumi.RegisterOutputType(PolicyOutput{}) 329 pulumi.RegisterOutputType(PolicyArrayOutput{}) 330 pulumi.RegisterOutputType(PolicyMapOutput{}) 331 }