github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ecr/pullThroughCacheRule.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 ecr
     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 an Elastic Container Registry Pull Through Cache Rule.
    16  //
    17  // More information about pull through cache rules, including the set of supported
    18  // upstream repositories, see [Using pull through cache rules](https://docs.aws.amazon.com/AmazonECR/latest/userguide/pull-through-cache.html).
    19  //
    20  // ## Example Usage
    21  //
    22  // <!--Start PulumiCodeChooser -->
    23  // ```go
    24  // package main
    25  //
    26  // import (
    27  //
    28  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ecr"
    29  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    30  //
    31  // )
    32  //
    33  //	func main() {
    34  //		pulumi.Run(func(ctx *pulumi.Context) error {
    35  //			_, err := ecr.NewPullThroughCacheRule(ctx, "example", &ecr.PullThroughCacheRuleArgs{
    36  //				EcrRepositoryPrefix: pulumi.String("ecr-public"),
    37  //				UpstreamRegistryUrl: pulumi.String("public.ecr.aws"),
    38  //				CredentialArn:       pulumi.String("arn:aws:secretsmanager:us-east-1:123456789:secret:ecr-pullthroughcache/ecrpublic"),
    39  //			})
    40  //			if err != nil {
    41  //				return err
    42  //			}
    43  //			return nil
    44  //		})
    45  //	}
    46  //
    47  // ```
    48  // <!--End PulumiCodeChooser -->
    49  //
    50  // ## Import
    51  //
    52  // Using `pulumi import`, import a pull-through cache rule using the `ecr_repository_prefix`. For example:
    53  //
    54  // ```sh
    55  // $ pulumi import aws:ecr/pullThroughCacheRule:PullThroughCacheRule example ecr-public
    56  // ```
    57  type PullThroughCacheRule struct {
    58  	pulumi.CustomResourceState
    59  
    60  	// ARN of the Secret which will be used to authenticate against the registry.
    61  	CredentialArn pulumi.StringPtrOutput `pulumi:"credentialArn"`
    62  	// The repository name prefix to use when caching images from the source registry.
    63  	EcrRepositoryPrefix pulumi.StringOutput `pulumi:"ecrRepositoryPrefix"`
    64  	// The registry ID where the repository was created.
    65  	RegistryId pulumi.StringOutput `pulumi:"registryId"`
    66  	// The registry URL of the upstream public registry to use as the source.
    67  	UpstreamRegistryUrl pulumi.StringOutput `pulumi:"upstreamRegistryUrl"`
    68  }
    69  
    70  // NewPullThroughCacheRule registers a new resource with the given unique name, arguments, and options.
    71  func NewPullThroughCacheRule(ctx *pulumi.Context,
    72  	name string, args *PullThroughCacheRuleArgs, opts ...pulumi.ResourceOption) (*PullThroughCacheRule, error) {
    73  	if args == nil {
    74  		return nil, errors.New("missing one or more required arguments")
    75  	}
    76  
    77  	if args.EcrRepositoryPrefix == nil {
    78  		return nil, errors.New("invalid value for required argument 'EcrRepositoryPrefix'")
    79  	}
    80  	if args.UpstreamRegistryUrl == nil {
    81  		return nil, errors.New("invalid value for required argument 'UpstreamRegistryUrl'")
    82  	}
    83  	opts = internal.PkgResourceDefaultOpts(opts)
    84  	var resource PullThroughCacheRule
    85  	err := ctx.RegisterResource("aws:ecr/pullThroughCacheRule:PullThroughCacheRule", name, args, &resource, opts...)
    86  	if err != nil {
    87  		return nil, err
    88  	}
    89  	return &resource, nil
    90  }
    91  
    92  // GetPullThroughCacheRule gets an existing PullThroughCacheRule resource's state with the given name, ID, and optional
    93  // state properties that are used to uniquely qualify the lookup (nil if not required).
    94  func GetPullThroughCacheRule(ctx *pulumi.Context,
    95  	name string, id pulumi.IDInput, state *PullThroughCacheRuleState, opts ...pulumi.ResourceOption) (*PullThroughCacheRule, error) {
    96  	var resource PullThroughCacheRule
    97  	err := ctx.ReadResource("aws:ecr/pullThroughCacheRule:PullThroughCacheRule", name, id, state, &resource, opts...)
    98  	if err != nil {
    99  		return nil, err
   100  	}
   101  	return &resource, nil
   102  }
   103  
   104  // Input properties used for looking up and filtering PullThroughCacheRule resources.
   105  type pullThroughCacheRuleState struct {
   106  	// ARN of the Secret which will be used to authenticate against the registry.
   107  	CredentialArn *string `pulumi:"credentialArn"`
   108  	// The repository name prefix to use when caching images from the source registry.
   109  	EcrRepositoryPrefix *string `pulumi:"ecrRepositoryPrefix"`
   110  	// The registry ID where the repository was created.
   111  	RegistryId *string `pulumi:"registryId"`
   112  	// The registry URL of the upstream public registry to use as the source.
   113  	UpstreamRegistryUrl *string `pulumi:"upstreamRegistryUrl"`
   114  }
   115  
   116  type PullThroughCacheRuleState struct {
   117  	// ARN of the Secret which will be used to authenticate against the registry.
   118  	CredentialArn pulumi.StringPtrInput
   119  	// The repository name prefix to use when caching images from the source registry.
   120  	EcrRepositoryPrefix pulumi.StringPtrInput
   121  	// The registry ID where the repository was created.
   122  	RegistryId pulumi.StringPtrInput
   123  	// The registry URL of the upstream public registry to use as the source.
   124  	UpstreamRegistryUrl pulumi.StringPtrInput
   125  }
   126  
   127  func (PullThroughCacheRuleState) ElementType() reflect.Type {
   128  	return reflect.TypeOf((*pullThroughCacheRuleState)(nil)).Elem()
   129  }
   130  
   131  type pullThroughCacheRuleArgs struct {
   132  	// ARN of the Secret which will be used to authenticate against the registry.
   133  	CredentialArn *string `pulumi:"credentialArn"`
   134  	// The repository name prefix to use when caching images from the source registry.
   135  	EcrRepositoryPrefix string `pulumi:"ecrRepositoryPrefix"`
   136  	// The registry URL of the upstream public registry to use as the source.
   137  	UpstreamRegistryUrl string `pulumi:"upstreamRegistryUrl"`
   138  }
   139  
   140  // The set of arguments for constructing a PullThroughCacheRule resource.
   141  type PullThroughCacheRuleArgs struct {
   142  	// ARN of the Secret which will be used to authenticate against the registry.
   143  	CredentialArn pulumi.StringPtrInput
   144  	// The repository name prefix to use when caching images from the source registry.
   145  	EcrRepositoryPrefix pulumi.StringInput
   146  	// The registry URL of the upstream public registry to use as the source.
   147  	UpstreamRegistryUrl pulumi.StringInput
   148  }
   149  
   150  func (PullThroughCacheRuleArgs) ElementType() reflect.Type {
   151  	return reflect.TypeOf((*pullThroughCacheRuleArgs)(nil)).Elem()
   152  }
   153  
   154  type PullThroughCacheRuleInput interface {
   155  	pulumi.Input
   156  
   157  	ToPullThroughCacheRuleOutput() PullThroughCacheRuleOutput
   158  	ToPullThroughCacheRuleOutputWithContext(ctx context.Context) PullThroughCacheRuleOutput
   159  }
   160  
   161  func (*PullThroughCacheRule) ElementType() reflect.Type {
   162  	return reflect.TypeOf((**PullThroughCacheRule)(nil)).Elem()
   163  }
   164  
   165  func (i *PullThroughCacheRule) ToPullThroughCacheRuleOutput() PullThroughCacheRuleOutput {
   166  	return i.ToPullThroughCacheRuleOutputWithContext(context.Background())
   167  }
   168  
   169  func (i *PullThroughCacheRule) ToPullThroughCacheRuleOutputWithContext(ctx context.Context) PullThroughCacheRuleOutput {
   170  	return pulumi.ToOutputWithContext(ctx, i).(PullThroughCacheRuleOutput)
   171  }
   172  
   173  // PullThroughCacheRuleArrayInput is an input type that accepts PullThroughCacheRuleArray and PullThroughCacheRuleArrayOutput values.
   174  // You can construct a concrete instance of `PullThroughCacheRuleArrayInput` via:
   175  //
   176  //	PullThroughCacheRuleArray{ PullThroughCacheRuleArgs{...} }
   177  type PullThroughCacheRuleArrayInput interface {
   178  	pulumi.Input
   179  
   180  	ToPullThroughCacheRuleArrayOutput() PullThroughCacheRuleArrayOutput
   181  	ToPullThroughCacheRuleArrayOutputWithContext(context.Context) PullThroughCacheRuleArrayOutput
   182  }
   183  
   184  type PullThroughCacheRuleArray []PullThroughCacheRuleInput
   185  
   186  func (PullThroughCacheRuleArray) ElementType() reflect.Type {
   187  	return reflect.TypeOf((*[]*PullThroughCacheRule)(nil)).Elem()
   188  }
   189  
   190  func (i PullThroughCacheRuleArray) ToPullThroughCacheRuleArrayOutput() PullThroughCacheRuleArrayOutput {
   191  	return i.ToPullThroughCacheRuleArrayOutputWithContext(context.Background())
   192  }
   193  
   194  func (i PullThroughCacheRuleArray) ToPullThroughCacheRuleArrayOutputWithContext(ctx context.Context) PullThroughCacheRuleArrayOutput {
   195  	return pulumi.ToOutputWithContext(ctx, i).(PullThroughCacheRuleArrayOutput)
   196  }
   197  
   198  // PullThroughCacheRuleMapInput is an input type that accepts PullThroughCacheRuleMap and PullThroughCacheRuleMapOutput values.
   199  // You can construct a concrete instance of `PullThroughCacheRuleMapInput` via:
   200  //
   201  //	PullThroughCacheRuleMap{ "key": PullThroughCacheRuleArgs{...} }
   202  type PullThroughCacheRuleMapInput interface {
   203  	pulumi.Input
   204  
   205  	ToPullThroughCacheRuleMapOutput() PullThroughCacheRuleMapOutput
   206  	ToPullThroughCacheRuleMapOutputWithContext(context.Context) PullThroughCacheRuleMapOutput
   207  }
   208  
   209  type PullThroughCacheRuleMap map[string]PullThroughCacheRuleInput
   210  
   211  func (PullThroughCacheRuleMap) ElementType() reflect.Type {
   212  	return reflect.TypeOf((*map[string]*PullThroughCacheRule)(nil)).Elem()
   213  }
   214  
   215  func (i PullThroughCacheRuleMap) ToPullThroughCacheRuleMapOutput() PullThroughCacheRuleMapOutput {
   216  	return i.ToPullThroughCacheRuleMapOutputWithContext(context.Background())
   217  }
   218  
   219  func (i PullThroughCacheRuleMap) ToPullThroughCacheRuleMapOutputWithContext(ctx context.Context) PullThroughCacheRuleMapOutput {
   220  	return pulumi.ToOutputWithContext(ctx, i).(PullThroughCacheRuleMapOutput)
   221  }
   222  
   223  type PullThroughCacheRuleOutput struct{ *pulumi.OutputState }
   224  
   225  func (PullThroughCacheRuleOutput) ElementType() reflect.Type {
   226  	return reflect.TypeOf((**PullThroughCacheRule)(nil)).Elem()
   227  }
   228  
   229  func (o PullThroughCacheRuleOutput) ToPullThroughCacheRuleOutput() PullThroughCacheRuleOutput {
   230  	return o
   231  }
   232  
   233  func (o PullThroughCacheRuleOutput) ToPullThroughCacheRuleOutputWithContext(ctx context.Context) PullThroughCacheRuleOutput {
   234  	return o
   235  }
   236  
   237  // ARN of the Secret which will be used to authenticate against the registry.
   238  func (o PullThroughCacheRuleOutput) CredentialArn() pulumi.StringPtrOutput {
   239  	return o.ApplyT(func(v *PullThroughCacheRule) pulumi.StringPtrOutput { return v.CredentialArn }).(pulumi.StringPtrOutput)
   240  }
   241  
   242  // The repository name prefix to use when caching images from the source registry.
   243  func (o PullThroughCacheRuleOutput) EcrRepositoryPrefix() pulumi.StringOutput {
   244  	return o.ApplyT(func(v *PullThroughCacheRule) pulumi.StringOutput { return v.EcrRepositoryPrefix }).(pulumi.StringOutput)
   245  }
   246  
   247  // The registry ID where the repository was created.
   248  func (o PullThroughCacheRuleOutput) RegistryId() pulumi.StringOutput {
   249  	return o.ApplyT(func(v *PullThroughCacheRule) pulumi.StringOutput { return v.RegistryId }).(pulumi.StringOutput)
   250  }
   251  
   252  // The registry URL of the upstream public registry to use as the source.
   253  func (o PullThroughCacheRuleOutput) UpstreamRegistryUrl() pulumi.StringOutput {
   254  	return o.ApplyT(func(v *PullThroughCacheRule) pulumi.StringOutput { return v.UpstreamRegistryUrl }).(pulumi.StringOutput)
   255  }
   256  
   257  type PullThroughCacheRuleArrayOutput struct{ *pulumi.OutputState }
   258  
   259  func (PullThroughCacheRuleArrayOutput) ElementType() reflect.Type {
   260  	return reflect.TypeOf((*[]*PullThroughCacheRule)(nil)).Elem()
   261  }
   262  
   263  func (o PullThroughCacheRuleArrayOutput) ToPullThroughCacheRuleArrayOutput() PullThroughCacheRuleArrayOutput {
   264  	return o
   265  }
   266  
   267  func (o PullThroughCacheRuleArrayOutput) ToPullThroughCacheRuleArrayOutputWithContext(ctx context.Context) PullThroughCacheRuleArrayOutput {
   268  	return o
   269  }
   270  
   271  func (o PullThroughCacheRuleArrayOutput) Index(i pulumi.IntInput) PullThroughCacheRuleOutput {
   272  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *PullThroughCacheRule {
   273  		return vs[0].([]*PullThroughCacheRule)[vs[1].(int)]
   274  	}).(PullThroughCacheRuleOutput)
   275  }
   276  
   277  type PullThroughCacheRuleMapOutput struct{ *pulumi.OutputState }
   278  
   279  func (PullThroughCacheRuleMapOutput) ElementType() reflect.Type {
   280  	return reflect.TypeOf((*map[string]*PullThroughCacheRule)(nil)).Elem()
   281  }
   282  
   283  func (o PullThroughCacheRuleMapOutput) ToPullThroughCacheRuleMapOutput() PullThroughCacheRuleMapOutput {
   284  	return o
   285  }
   286  
   287  func (o PullThroughCacheRuleMapOutput) ToPullThroughCacheRuleMapOutputWithContext(ctx context.Context) PullThroughCacheRuleMapOutput {
   288  	return o
   289  }
   290  
   291  func (o PullThroughCacheRuleMapOutput) MapIndex(k pulumi.StringInput) PullThroughCacheRuleOutput {
   292  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *PullThroughCacheRule {
   293  		return vs[0].(map[string]*PullThroughCacheRule)[vs[1].(string)]
   294  	}).(PullThroughCacheRuleOutput)
   295  }
   296  
   297  func init() {
   298  	pulumi.RegisterInputType(reflect.TypeOf((*PullThroughCacheRuleInput)(nil)).Elem(), &PullThroughCacheRule{})
   299  	pulumi.RegisterInputType(reflect.TypeOf((*PullThroughCacheRuleArrayInput)(nil)).Elem(), PullThroughCacheRuleArray{})
   300  	pulumi.RegisterInputType(reflect.TypeOf((*PullThroughCacheRuleMapInput)(nil)).Elem(), PullThroughCacheRuleMap{})
   301  	pulumi.RegisterOutputType(PullThroughCacheRuleOutput{})
   302  	pulumi.RegisterOutputType(PullThroughCacheRuleArrayOutput{})
   303  	pulumi.RegisterOutputType(PullThroughCacheRuleMapOutput{})
   304  }