github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ecs/getTaskDefinition.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 ecs
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    11  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    12  )
    13  
    14  // The ECS task definition data source allows access to details of
    15  // a specific AWS ECS task definition.
    16  //
    17  // ## Example Usage
    18  //
    19  // <!--Start PulumiCodeChooser -->
    20  // ```go
    21  // package main
    22  //
    23  // import (
    24  //
    25  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ecs"
    26  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    27  //
    28  // )
    29  //
    30  //	func main() {
    31  //		pulumi.Run(func(ctx *pulumi.Context) error {
    32  //			mongoTaskDefinition, err := ecs.NewTaskDefinition(ctx, "mongo", &ecs.TaskDefinitionArgs{
    33  //				Family: pulumi.String("mongodb"),
    34  //				ContainerDefinitions: pulumi.String(`[
    35  //	  {
    36  //	    "cpu": 128,
    37  //	    "environment": [{
    38  //	      "name": "SECRET",
    39  //	      "value": "KEY"
    40  //	    }],
    41  //	    "essential": true,
    42  //	    "image": "mongo:latest",
    43  //	    "memory": 128,
    44  //	    "memoryReservation": 64,
    45  //	    "name": "mongodb"
    46  //	  }
    47  //
    48  // ]
    49  // `),
    50  //
    51  //			})
    52  //			if err != nil {
    53  //				return err
    54  //			}
    55  //			// Simply specify the family to find the latest ACTIVE revision in that family.
    56  //			mongo := ecs.LookupTaskDefinitionOutput(ctx, ecs.GetTaskDefinitionOutputArgs{
    57  //				TaskDefinition: mongoTaskDefinition.Family,
    58  //			}, nil)
    59  //			foo, err := ecs.NewCluster(ctx, "foo", &ecs.ClusterArgs{
    60  //				Name: pulumi.String("foo"),
    61  //			})
    62  //			if err != nil {
    63  //				return err
    64  //			}
    65  //			_, err = ecs.NewService(ctx, "mongo", &ecs.ServiceArgs{
    66  //				Name:         pulumi.String("mongo"),
    67  //				Cluster:      foo.ID(),
    68  //				DesiredCount: pulumi.Int(2),
    69  //				TaskDefinition: mongo.ApplyT(func(mongo ecs.GetTaskDefinitionResult) (*string, error) {
    70  //					return &mongo.Arn, nil
    71  //				}).(pulumi.StringPtrOutput),
    72  //			})
    73  //			if err != nil {
    74  //				return err
    75  //			}
    76  //			return nil
    77  //		})
    78  //	}
    79  //
    80  // ```
    81  // <!--End PulumiCodeChooser -->
    82  func LookupTaskDefinition(ctx *pulumi.Context, args *LookupTaskDefinitionArgs, opts ...pulumi.InvokeOption) (*LookupTaskDefinitionResult, error) {
    83  	opts = internal.PkgInvokeDefaultOpts(opts)
    84  	var rv LookupTaskDefinitionResult
    85  	err := ctx.Invoke("aws:ecs/getTaskDefinition:getTaskDefinition", args, &rv, opts...)
    86  	if err != nil {
    87  		return nil, err
    88  	}
    89  	return &rv, nil
    90  }
    91  
    92  // A collection of arguments for invoking getTaskDefinition.
    93  type LookupTaskDefinitionArgs struct {
    94  	// Family for the latest ACTIVE revision, family and revision (family:revision) for a specific revision in the family, the ARN of the task definition to access to.
    95  	TaskDefinition string `pulumi:"taskDefinition"`
    96  }
    97  
    98  // A collection of values returned by getTaskDefinition.
    99  type LookupTaskDefinitionResult struct {
   100  	// ARN of the task definition.
   101  	Arn string `pulumi:"arn"`
   102  	// ARN of the Task Definition with the trailing `revision` removed. This may be useful for situations where the latest task definition is always desired. If a revision isn't specified, the latest ACTIVE revision is used. See the [AWS documentation](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_StartTask.html#ECS-StartTask-request-taskDefinition) for details.
   103  	ArnWithoutRevision string `pulumi:"arnWithoutRevision"`
   104  	// ARN of the task execution role that the Amazon ECS container agent and the Docker.
   105  	ExecutionRoleArn string `pulumi:"executionRoleArn"`
   106  	// Family of this task definition.
   107  	Family string `pulumi:"family"`
   108  	// The provider-assigned unique ID for this managed resource.
   109  	Id string `pulumi:"id"`
   110  	// Docker networking mode to use for the containers in this task.
   111  	NetworkMode string `pulumi:"networkMode"`
   112  	// Revision of this task definition.
   113  	Revision int `pulumi:"revision"`
   114  	// Status of this task definition.
   115  	Status         string `pulumi:"status"`
   116  	TaskDefinition string `pulumi:"taskDefinition"`
   117  	// ARN of the IAM role that containers in this task can assume.
   118  	TaskRoleArn string `pulumi:"taskRoleArn"`
   119  }
   120  
   121  func LookupTaskDefinitionOutput(ctx *pulumi.Context, args LookupTaskDefinitionOutputArgs, opts ...pulumi.InvokeOption) LookupTaskDefinitionResultOutput {
   122  	return pulumi.ToOutputWithContext(context.Background(), args).
   123  		ApplyT(func(v interface{}) (LookupTaskDefinitionResult, error) {
   124  			args := v.(LookupTaskDefinitionArgs)
   125  			r, err := LookupTaskDefinition(ctx, &args, opts...)
   126  			var s LookupTaskDefinitionResult
   127  			if r != nil {
   128  				s = *r
   129  			}
   130  			return s, err
   131  		}).(LookupTaskDefinitionResultOutput)
   132  }
   133  
   134  // A collection of arguments for invoking getTaskDefinition.
   135  type LookupTaskDefinitionOutputArgs struct {
   136  	// Family for the latest ACTIVE revision, family and revision (family:revision) for a specific revision in the family, the ARN of the task definition to access to.
   137  	TaskDefinition pulumi.StringInput `pulumi:"taskDefinition"`
   138  }
   139  
   140  func (LookupTaskDefinitionOutputArgs) ElementType() reflect.Type {
   141  	return reflect.TypeOf((*LookupTaskDefinitionArgs)(nil)).Elem()
   142  }
   143  
   144  // A collection of values returned by getTaskDefinition.
   145  type LookupTaskDefinitionResultOutput struct{ *pulumi.OutputState }
   146  
   147  func (LookupTaskDefinitionResultOutput) ElementType() reflect.Type {
   148  	return reflect.TypeOf((*LookupTaskDefinitionResult)(nil)).Elem()
   149  }
   150  
   151  func (o LookupTaskDefinitionResultOutput) ToLookupTaskDefinitionResultOutput() LookupTaskDefinitionResultOutput {
   152  	return o
   153  }
   154  
   155  func (o LookupTaskDefinitionResultOutput) ToLookupTaskDefinitionResultOutputWithContext(ctx context.Context) LookupTaskDefinitionResultOutput {
   156  	return o
   157  }
   158  
   159  // ARN of the task definition.
   160  func (o LookupTaskDefinitionResultOutput) Arn() pulumi.StringOutput {
   161  	return o.ApplyT(func(v LookupTaskDefinitionResult) string { return v.Arn }).(pulumi.StringOutput)
   162  }
   163  
   164  // ARN of the Task Definition with the trailing `revision` removed. This may be useful for situations where the latest task definition is always desired. If a revision isn't specified, the latest ACTIVE revision is used. See the [AWS documentation](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_StartTask.html#ECS-StartTask-request-taskDefinition) for details.
   165  func (o LookupTaskDefinitionResultOutput) ArnWithoutRevision() pulumi.StringOutput {
   166  	return o.ApplyT(func(v LookupTaskDefinitionResult) string { return v.ArnWithoutRevision }).(pulumi.StringOutput)
   167  }
   168  
   169  // ARN of the task execution role that the Amazon ECS container agent and the Docker.
   170  func (o LookupTaskDefinitionResultOutput) ExecutionRoleArn() pulumi.StringOutput {
   171  	return o.ApplyT(func(v LookupTaskDefinitionResult) string { return v.ExecutionRoleArn }).(pulumi.StringOutput)
   172  }
   173  
   174  // Family of this task definition.
   175  func (o LookupTaskDefinitionResultOutput) Family() pulumi.StringOutput {
   176  	return o.ApplyT(func(v LookupTaskDefinitionResult) string { return v.Family }).(pulumi.StringOutput)
   177  }
   178  
   179  // The provider-assigned unique ID for this managed resource.
   180  func (o LookupTaskDefinitionResultOutput) Id() pulumi.StringOutput {
   181  	return o.ApplyT(func(v LookupTaskDefinitionResult) string { return v.Id }).(pulumi.StringOutput)
   182  }
   183  
   184  // Docker networking mode to use for the containers in this task.
   185  func (o LookupTaskDefinitionResultOutput) NetworkMode() pulumi.StringOutput {
   186  	return o.ApplyT(func(v LookupTaskDefinitionResult) string { return v.NetworkMode }).(pulumi.StringOutput)
   187  }
   188  
   189  // Revision of this task definition.
   190  func (o LookupTaskDefinitionResultOutput) Revision() pulumi.IntOutput {
   191  	return o.ApplyT(func(v LookupTaskDefinitionResult) int { return v.Revision }).(pulumi.IntOutput)
   192  }
   193  
   194  // Status of this task definition.
   195  func (o LookupTaskDefinitionResultOutput) Status() pulumi.StringOutput {
   196  	return o.ApplyT(func(v LookupTaskDefinitionResult) string { return v.Status }).(pulumi.StringOutput)
   197  }
   198  
   199  func (o LookupTaskDefinitionResultOutput) TaskDefinition() pulumi.StringOutput {
   200  	return o.ApplyT(func(v LookupTaskDefinitionResult) string { return v.TaskDefinition }).(pulumi.StringOutput)
   201  }
   202  
   203  // ARN of the IAM role that containers in this task can assume.
   204  func (o LookupTaskDefinitionResultOutput) TaskRoleArn() pulumi.StringOutput {
   205  	return o.ApplyT(func(v LookupTaskDefinitionResult) string { return v.TaskRoleArn }).(pulumi.StringOutput)
   206  }
   207  
   208  func init() {
   209  	pulumi.RegisterOutputType(LookupTaskDefinitionResultOutput{})
   210  }