github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/msk/clusterPolicy.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 msk
     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  // Resource for managing an AWS Managed Streaming for Kafka Cluster Policy.
    16  //
    17  // ## Example Usage
    18  //
    19  // ### Basic Usage
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"encoding/json"
    28  //	"fmt"
    29  //
    30  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
    31  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/msk"
    32  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    33  //
    34  // )
    35  //
    36  //	func main() {
    37  //		pulumi.Run(func(ctx *pulumi.Context) error {
    38  //			current, err := aws.GetCallerIdentity(ctx, nil, nil)
    39  //			if err != nil {
    40  //				return err
    41  //			}
    42  //			currentGetPartition, err := aws.GetPartition(ctx, nil, nil)
    43  //			if err != nil {
    44  //				return err
    45  //			}
    46  //			tmpJSON0, err := json.Marshal(map[string]interface{}{
    47  //				"Version": "2012-10-17",
    48  //				"Statement": []map[string]interface{}{
    49  //					map[string]interface{}{
    50  //						"Sid":    "ExampleMskClusterPolicy",
    51  //						"Effect": "Allow",
    52  //						"Principal": map[string]interface{}{
    53  //							"AWS": fmt.Sprintf("arn:%v:iam::%v:root", currentGetPartition.Partition, current.AccountId),
    54  //						},
    55  //						"Action": []string{
    56  //							"kafka:Describe*",
    57  //							"kafka:Get*",
    58  //							"kafka:CreateVpcConnection",
    59  //							"kafka:GetBootstrapBrokers",
    60  //						},
    61  //						"Resource": exampleAwsMskCluster.Arn,
    62  //					},
    63  //				},
    64  //			})
    65  //			if err != nil {
    66  //				return err
    67  //			}
    68  //			json0 := string(tmpJSON0)
    69  //			_, err = msk.NewClusterPolicy(ctx, "example", &msk.ClusterPolicyArgs{
    70  //				ClusterArn: pulumi.Any(exampleAwsMskCluster.Arn),
    71  //				Policy:     pulumi.String(json0),
    72  //			})
    73  //			if err != nil {
    74  //				return err
    75  //			}
    76  //			return nil
    77  //		})
    78  //	}
    79  //
    80  // ```
    81  // <!--End PulumiCodeChooser -->
    82  //
    83  // ## Import
    84  //
    85  // Using `pulumi import`, import Managed Streaming for Kafka Cluster Policy using the `cluster_arn`. For example:
    86  //
    87  // ```sh
    88  // $ pulumi import aws:msk/clusterPolicy:ClusterPolicy example arn:aws:kafka:us-west-2:123456789012:cluster/example/279c0212-d057-4dba-9aa9-1c4e5a25bfc7-3
    89  // ```
    90  type ClusterPolicy struct {
    91  	pulumi.CustomResourceState
    92  
    93  	// The Amazon Resource Name (ARN) that uniquely identifies the cluster.
    94  	ClusterArn     pulumi.StringOutput `pulumi:"clusterArn"`
    95  	CurrentVersion pulumi.StringOutput `pulumi:"currentVersion"`
    96  	// Resource policy for cluster.
    97  	Policy pulumi.StringOutput `pulumi:"policy"`
    98  }
    99  
   100  // NewClusterPolicy registers a new resource with the given unique name, arguments, and options.
   101  func NewClusterPolicy(ctx *pulumi.Context,
   102  	name string, args *ClusterPolicyArgs, opts ...pulumi.ResourceOption) (*ClusterPolicy, error) {
   103  	if args == nil {
   104  		return nil, errors.New("missing one or more required arguments")
   105  	}
   106  
   107  	if args.ClusterArn == nil {
   108  		return nil, errors.New("invalid value for required argument 'ClusterArn'")
   109  	}
   110  	if args.Policy == nil {
   111  		return nil, errors.New("invalid value for required argument 'Policy'")
   112  	}
   113  	opts = internal.PkgResourceDefaultOpts(opts)
   114  	var resource ClusterPolicy
   115  	err := ctx.RegisterResource("aws:msk/clusterPolicy:ClusterPolicy", name, args, &resource, opts...)
   116  	if err != nil {
   117  		return nil, err
   118  	}
   119  	return &resource, nil
   120  }
   121  
   122  // GetClusterPolicy gets an existing ClusterPolicy resource's state with the given name, ID, and optional
   123  // state properties that are used to uniquely qualify the lookup (nil if not required).
   124  func GetClusterPolicy(ctx *pulumi.Context,
   125  	name string, id pulumi.IDInput, state *ClusterPolicyState, opts ...pulumi.ResourceOption) (*ClusterPolicy, error) {
   126  	var resource ClusterPolicy
   127  	err := ctx.ReadResource("aws:msk/clusterPolicy:ClusterPolicy", name, id, state, &resource, opts...)
   128  	if err != nil {
   129  		return nil, err
   130  	}
   131  	return &resource, nil
   132  }
   133  
   134  // Input properties used for looking up and filtering ClusterPolicy resources.
   135  type clusterPolicyState struct {
   136  	// The Amazon Resource Name (ARN) that uniquely identifies the cluster.
   137  	ClusterArn     *string `pulumi:"clusterArn"`
   138  	CurrentVersion *string `pulumi:"currentVersion"`
   139  	// Resource policy for cluster.
   140  	Policy *string `pulumi:"policy"`
   141  }
   142  
   143  type ClusterPolicyState struct {
   144  	// The Amazon Resource Name (ARN) that uniquely identifies the cluster.
   145  	ClusterArn     pulumi.StringPtrInput
   146  	CurrentVersion pulumi.StringPtrInput
   147  	// Resource policy for cluster.
   148  	Policy pulumi.StringPtrInput
   149  }
   150  
   151  func (ClusterPolicyState) ElementType() reflect.Type {
   152  	return reflect.TypeOf((*clusterPolicyState)(nil)).Elem()
   153  }
   154  
   155  type clusterPolicyArgs struct {
   156  	// The Amazon Resource Name (ARN) that uniquely identifies the cluster.
   157  	ClusterArn string `pulumi:"clusterArn"`
   158  	// Resource policy for cluster.
   159  	Policy string `pulumi:"policy"`
   160  }
   161  
   162  // The set of arguments for constructing a ClusterPolicy resource.
   163  type ClusterPolicyArgs struct {
   164  	// The Amazon Resource Name (ARN) that uniquely identifies the cluster.
   165  	ClusterArn pulumi.StringInput
   166  	// Resource policy for cluster.
   167  	Policy pulumi.StringInput
   168  }
   169  
   170  func (ClusterPolicyArgs) ElementType() reflect.Type {
   171  	return reflect.TypeOf((*clusterPolicyArgs)(nil)).Elem()
   172  }
   173  
   174  type ClusterPolicyInput interface {
   175  	pulumi.Input
   176  
   177  	ToClusterPolicyOutput() ClusterPolicyOutput
   178  	ToClusterPolicyOutputWithContext(ctx context.Context) ClusterPolicyOutput
   179  }
   180  
   181  func (*ClusterPolicy) ElementType() reflect.Type {
   182  	return reflect.TypeOf((**ClusterPolicy)(nil)).Elem()
   183  }
   184  
   185  func (i *ClusterPolicy) ToClusterPolicyOutput() ClusterPolicyOutput {
   186  	return i.ToClusterPolicyOutputWithContext(context.Background())
   187  }
   188  
   189  func (i *ClusterPolicy) ToClusterPolicyOutputWithContext(ctx context.Context) ClusterPolicyOutput {
   190  	return pulumi.ToOutputWithContext(ctx, i).(ClusterPolicyOutput)
   191  }
   192  
   193  // ClusterPolicyArrayInput is an input type that accepts ClusterPolicyArray and ClusterPolicyArrayOutput values.
   194  // You can construct a concrete instance of `ClusterPolicyArrayInput` via:
   195  //
   196  //	ClusterPolicyArray{ ClusterPolicyArgs{...} }
   197  type ClusterPolicyArrayInput interface {
   198  	pulumi.Input
   199  
   200  	ToClusterPolicyArrayOutput() ClusterPolicyArrayOutput
   201  	ToClusterPolicyArrayOutputWithContext(context.Context) ClusterPolicyArrayOutput
   202  }
   203  
   204  type ClusterPolicyArray []ClusterPolicyInput
   205  
   206  func (ClusterPolicyArray) ElementType() reflect.Type {
   207  	return reflect.TypeOf((*[]*ClusterPolicy)(nil)).Elem()
   208  }
   209  
   210  func (i ClusterPolicyArray) ToClusterPolicyArrayOutput() ClusterPolicyArrayOutput {
   211  	return i.ToClusterPolicyArrayOutputWithContext(context.Background())
   212  }
   213  
   214  func (i ClusterPolicyArray) ToClusterPolicyArrayOutputWithContext(ctx context.Context) ClusterPolicyArrayOutput {
   215  	return pulumi.ToOutputWithContext(ctx, i).(ClusterPolicyArrayOutput)
   216  }
   217  
   218  // ClusterPolicyMapInput is an input type that accepts ClusterPolicyMap and ClusterPolicyMapOutput values.
   219  // You can construct a concrete instance of `ClusterPolicyMapInput` via:
   220  //
   221  //	ClusterPolicyMap{ "key": ClusterPolicyArgs{...} }
   222  type ClusterPolicyMapInput interface {
   223  	pulumi.Input
   224  
   225  	ToClusterPolicyMapOutput() ClusterPolicyMapOutput
   226  	ToClusterPolicyMapOutputWithContext(context.Context) ClusterPolicyMapOutput
   227  }
   228  
   229  type ClusterPolicyMap map[string]ClusterPolicyInput
   230  
   231  func (ClusterPolicyMap) ElementType() reflect.Type {
   232  	return reflect.TypeOf((*map[string]*ClusterPolicy)(nil)).Elem()
   233  }
   234  
   235  func (i ClusterPolicyMap) ToClusterPolicyMapOutput() ClusterPolicyMapOutput {
   236  	return i.ToClusterPolicyMapOutputWithContext(context.Background())
   237  }
   238  
   239  func (i ClusterPolicyMap) ToClusterPolicyMapOutputWithContext(ctx context.Context) ClusterPolicyMapOutput {
   240  	return pulumi.ToOutputWithContext(ctx, i).(ClusterPolicyMapOutput)
   241  }
   242  
   243  type ClusterPolicyOutput struct{ *pulumi.OutputState }
   244  
   245  func (ClusterPolicyOutput) ElementType() reflect.Type {
   246  	return reflect.TypeOf((**ClusterPolicy)(nil)).Elem()
   247  }
   248  
   249  func (o ClusterPolicyOutput) ToClusterPolicyOutput() ClusterPolicyOutput {
   250  	return o
   251  }
   252  
   253  func (o ClusterPolicyOutput) ToClusterPolicyOutputWithContext(ctx context.Context) ClusterPolicyOutput {
   254  	return o
   255  }
   256  
   257  // The Amazon Resource Name (ARN) that uniquely identifies the cluster.
   258  func (o ClusterPolicyOutput) ClusterArn() pulumi.StringOutput {
   259  	return o.ApplyT(func(v *ClusterPolicy) pulumi.StringOutput { return v.ClusterArn }).(pulumi.StringOutput)
   260  }
   261  
   262  func (o ClusterPolicyOutput) CurrentVersion() pulumi.StringOutput {
   263  	return o.ApplyT(func(v *ClusterPolicy) pulumi.StringOutput { return v.CurrentVersion }).(pulumi.StringOutput)
   264  }
   265  
   266  // Resource policy for cluster.
   267  func (o ClusterPolicyOutput) Policy() pulumi.StringOutput {
   268  	return o.ApplyT(func(v *ClusterPolicy) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput)
   269  }
   270  
   271  type ClusterPolicyArrayOutput struct{ *pulumi.OutputState }
   272  
   273  func (ClusterPolicyArrayOutput) ElementType() reflect.Type {
   274  	return reflect.TypeOf((*[]*ClusterPolicy)(nil)).Elem()
   275  }
   276  
   277  func (o ClusterPolicyArrayOutput) ToClusterPolicyArrayOutput() ClusterPolicyArrayOutput {
   278  	return o
   279  }
   280  
   281  func (o ClusterPolicyArrayOutput) ToClusterPolicyArrayOutputWithContext(ctx context.Context) ClusterPolicyArrayOutput {
   282  	return o
   283  }
   284  
   285  func (o ClusterPolicyArrayOutput) Index(i pulumi.IntInput) ClusterPolicyOutput {
   286  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ClusterPolicy {
   287  		return vs[0].([]*ClusterPolicy)[vs[1].(int)]
   288  	}).(ClusterPolicyOutput)
   289  }
   290  
   291  type ClusterPolicyMapOutput struct{ *pulumi.OutputState }
   292  
   293  func (ClusterPolicyMapOutput) ElementType() reflect.Type {
   294  	return reflect.TypeOf((*map[string]*ClusterPolicy)(nil)).Elem()
   295  }
   296  
   297  func (o ClusterPolicyMapOutput) ToClusterPolicyMapOutput() ClusterPolicyMapOutput {
   298  	return o
   299  }
   300  
   301  func (o ClusterPolicyMapOutput) ToClusterPolicyMapOutputWithContext(ctx context.Context) ClusterPolicyMapOutput {
   302  	return o
   303  }
   304  
   305  func (o ClusterPolicyMapOutput) MapIndex(k pulumi.StringInput) ClusterPolicyOutput {
   306  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ClusterPolicy {
   307  		return vs[0].(map[string]*ClusterPolicy)[vs[1].(string)]
   308  	}).(ClusterPolicyOutput)
   309  }
   310  
   311  func init() {
   312  	pulumi.RegisterInputType(reflect.TypeOf((*ClusterPolicyInput)(nil)).Elem(), &ClusterPolicy{})
   313  	pulumi.RegisterInputType(reflect.TypeOf((*ClusterPolicyArrayInput)(nil)).Elem(), ClusterPolicyArray{})
   314  	pulumi.RegisterInputType(reflect.TypeOf((*ClusterPolicyMapInput)(nil)).Elem(), ClusterPolicyMap{})
   315  	pulumi.RegisterOutputType(ClusterPolicyOutput{})
   316  	pulumi.RegisterOutputType(ClusterPolicyArrayOutput{})
   317  	pulumi.RegisterOutputType(ClusterPolicyMapOutput{})
   318  }