github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ecs/getTaskExecution.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  // Data source for managing an AWS ECS (Elastic Container) Task Execution. This data source calls the [RunTask](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_RunTask.html) API, allowing execution of one-time tasks that don't fit a standard resource lifecycle. See the feature request issue for additional context.
    15  //
    16  // > **NOTE on preview operations:** This data source calls the `RunTask` API on every read operation, which means new task(s) may be created from a `pulumi preview` command if all attributes are known. Placing this functionality behind a data source is an intentional trade off to enable use cases requiring a one-time task execution without relying on provisioners. Caution should be taken to ensure the data source is only executed once, or that the resulting tasks can safely run in parallel.
    17  //
    18  // ## Example Usage
    19  //
    20  // ### Basic Usage
    21  //
    22  // <!--Start PulumiCodeChooser -->
    23  // ```go
    24  // package main
    25  //
    26  // import (
    27  //
    28  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ecs"
    29  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    30  //
    31  // )
    32  // func main() {
    33  // pulumi.Run(func(ctx *pulumi.Context) error {
    34  // _, err := ecs.GetTaskExecution(ctx, &ecs.GetTaskExecutionArgs{
    35  // Cluster: exampleAwsEcsCluster.Id,
    36  // TaskDefinition: exampleAwsEcsTaskDefinition.Arn,
    37  // DesiredCount: pulumi.IntRef(1),
    38  // LaunchType: pulumi.StringRef("FARGATE"),
    39  // NetworkConfiguration: ecs.GetTaskExecutionNetworkConfiguration{
    40  // Subnets: %!v(PANIC=Format method: fatal: A failure has occurred: unlowered splat expression @ example.pp:6,22-44),
    41  // SecurityGroups: interface{}{
    42  // exampleAwsSecurityGroup.Id,
    43  // },
    44  // AssignPublicIp: pulumi.BoolRef(false),
    45  // },
    46  // }, nil);
    47  // if err != nil {
    48  // return err
    49  // }
    50  // return nil
    51  // })
    52  // }
    53  // ```
    54  // <!--End PulumiCodeChooser -->
    55  func GetTaskExecution(ctx *pulumi.Context, args *GetTaskExecutionArgs, opts ...pulumi.InvokeOption) (*GetTaskExecutionResult, error) {
    56  	opts = internal.PkgInvokeDefaultOpts(opts)
    57  	var rv GetTaskExecutionResult
    58  	err := ctx.Invoke("aws:ecs/getTaskExecution:getTaskExecution", args, &rv, opts...)
    59  	if err != nil {
    60  		return nil, err
    61  	}
    62  	return &rv, nil
    63  }
    64  
    65  // A collection of arguments for invoking getTaskExecution.
    66  type GetTaskExecutionArgs struct {
    67  	// Set of capacity provider strategies to use for the cluster. See below.
    68  	CapacityProviderStrategies []GetTaskExecutionCapacityProviderStrategy `pulumi:"capacityProviderStrategies"`
    69  	// An identifier that you provide to ensure the idempotency of the request. It must be unique and is case sensitive. Up to 64 characters are allowed. The valid characters are characters in the range of 33-126, inclusive. For more information, see [Ensuring idempotency](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/ECS_Idempotency.html).
    70  	ClientToken *string `pulumi:"clientToken"`
    71  	// Short name or full Amazon Resource Name (ARN) of the cluster to run the task on.
    72  	Cluster string `pulumi:"cluster"`
    73  	// Number of instantiations of the specified task to place on your cluster. You can specify up to 10 tasks for each call.
    74  	DesiredCount *int `pulumi:"desiredCount"`
    75  	// Specifies whether to enable Amazon ECS managed tags for the tasks within the service.
    76  	EnableEcsManagedTags *bool `pulumi:"enableEcsManagedTags"`
    77  	// Specifies whether to enable Amazon ECS Exec for the tasks within the service.
    78  	EnableExecuteCommand *bool `pulumi:"enableExecuteCommand"`
    79  	// Name of the task group to associate with the task. The default value is the family name of the task definition.
    80  	Group *string `pulumi:"group"`
    81  	// Launch type on which to run your service. Valid values are `EC2`, `FARGATE`, and `EXTERNAL`.
    82  	LaunchType *string `pulumi:"launchType"`
    83  	// Network configuration for the service. This parameter is required for task definitions that use the `awsvpc` network mode to receive their own Elastic Network Interface, and it is not supported for other network modes. See below.
    84  	NetworkConfiguration *GetTaskExecutionNetworkConfiguration `pulumi:"networkConfiguration"`
    85  	// A list of container overrides that specify the name of a container in the specified task definition and the overrides it should receive.
    86  	Overrides *GetTaskExecutionOverrides `pulumi:"overrides"`
    87  	// An array of placement constraint objects to use for the task. You can specify up to 10 constraints for each task. See below.
    88  	PlacementConstraints []GetTaskExecutionPlacementConstraint `pulumi:"placementConstraints"`
    89  	// The placement strategy objects to use for the task. You can specify a maximum of 5 strategy rules for each task. See below.
    90  	PlacementStrategies []GetTaskExecutionPlacementStrategy `pulumi:"placementStrategies"`
    91  	// The platform version the task uses. A platform version is only specified for tasks hosted on Fargate. If one isn't specified, the `LATEST` platform version is used.
    92  	PlatformVersion *string `pulumi:"platformVersion"`
    93  	// Specifies whether to propagate the tags from the task definition to the task. If no value is specified, the tags aren't propagated. An error will be received if you specify the `SERVICE` option when running a task. Valid values are `TASK_DEFINITION` or `NONE`.
    94  	PropagateTags *string `pulumi:"propagateTags"`
    95  	// The reference ID to use for the task.
    96  	ReferenceId *string `pulumi:"referenceId"`
    97  	// An optional tag specified when a task is started.
    98  	StartedBy *string `pulumi:"startedBy"`
    99  	// Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   100  	Tags map[string]string `pulumi:"tags"`
   101  	// The `family` and `revision` (`family:revision`) or full ARN of the task definition to run. If a revision isn't specified, the latest `ACTIVE` revision is used.
   102  	//
   103  	// The following arguments are optional:
   104  	TaskDefinition string `pulumi:"taskDefinition"`
   105  }
   106  
   107  // A collection of values returned by getTaskExecution.
   108  type GetTaskExecutionResult struct {
   109  	CapacityProviderStrategies []GetTaskExecutionCapacityProviderStrategy `pulumi:"capacityProviderStrategies"`
   110  	ClientToken                *string                                    `pulumi:"clientToken"`
   111  	Cluster                    string                                     `pulumi:"cluster"`
   112  	DesiredCount               *int                                       `pulumi:"desiredCount"`
   113  	EnableEcsManagedTags       *bool                                      `pulumi:"enableEcsManagedTags"`
   114  	EnableExecuteCommand       *bool                                      `pulumi:"enableExecuteCommand"`
   115  	Group                      *string                                    `pulumi:"group"`
   116  	// The provider-assigned unique ID for this managed resource.
   117  	Id                   string                                `pulumi:"id"`
   118  	LaunchType           *string                               `pulumi:"launchType"`
   119  	NetworkConfiguration *GetTaskExecutionNetworkConfiguration `pulumi:"networkConfiguration"`
   120  	Overrides            *GetTaskExecutionOverrides            `pulumi:"overrides"`
   121  	PlacementConstraints []GetTaskExecutionPlacementConstraint `pulumi:"placementConstraints"`
   122  	PlacementStrategies  []GetTaskExecutionPlacementStrategy   `pulumi:"placementStrategies"`
   123  	PlatformVersion      *string                               `pulumi:"platformVersion"`
   124  	PropagateTags        *string                               `pulumi:"propagateTags"`
   125  	ReferenceId          *string                               `pulumi:"referenceId"`
   126  	StartedBy            *string                               `pulumi:"startedBy"`
   127  	Tags                 map[string]string                     `pulumi:"tags"`
   128  	// A list of the provisioned task ARNs.
   129  	TaskArns       []string `pulumi:"taskArns"`
   130  	TaskDefinition string   `pulumi:"taskDefinition"`
   131  }
   132  
   133  func GetTaskExecutionOutput(ctx *pulumi.Context, args GetTaskExecutionOutputArgs, opts ...pulumi.InvokeOption) GetTaskExecutionResultOutput {
   134  	return pulumi.ToOutputWithContext(context.Background(), args).
   135  		ApplyT(func(v interface{}) (GetTaskExecutionResult, error) {
   136  			args := v.(GetTaskExecutionArgs)
   137  			r, err := GetTaskExecution(ctx, &args, opts...)
   138  			var s GetTaskExecutionResult
   139  			if r != nil {
   140  				s = *r
   141  			}
   142  			return s, err
   143  		}).(GetTaskExecutionResultOutput)
   144  }
   145  
   146  // A collection of arguments for invoking getTaskExecution.
   147  type GetTaskExecutionOutputArgs struct {
   148  	// Set of capacity provider strategies to use for the cluster. See below.
   149  	CapacityProviderStrategies GetTaskExecutionCapacityProviderStrategyArrayInput `pulumi:"capacityProviderStrategies"`
   150  	// An identifier that you provide to ensure the idempotency of the request. It must be unique and is case sensitive. Up to 64 characters are allowed. The valid characters are characters in the range of 33-126, inclusive. For more information, see [Ensuring idempotency](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/ECS_Idempotency.html).
   151  	ClientToken pulumi.StringPtrInput `pulumi:"clientToken"`
   152  	// Short name or full Amazon Resource Name (ARN) of the cluster to run the task on.
   153  	Cluster pulumi.StringInput `pulumi:"cluster"`
   154  	// Number of instantiations of the specified task to place on your cluster. You can specify up to 10 tasks for each call.
   155  	DesiredCount pulumi.IntPtrInput `pulumi:"desiredCount"`
   156  	// Specifies whether to enable Amazon ECS managed tags for the tasks within the service.
   157  	EnableEcsManagedTags pulumi.BoolPtrInput `pulumi:"enableEcsManagedTags"`
   158  	// Specifies whether to enable Amazon ECS Exec for the tasks within the service.
   159  	EnableExecuteCommand pulumi.BoolPtrInput `pulumi:"enableExecuteCommand"`
   160  	// Name of the task group to associate with the task. The default value is the family name of the task definition.
   161  	Group pulumi.StringPtrInput `pulumi:"group"`
   162  	// Launch type on which to run your service. Valid values are `EC2`, `FARGATE`, and `EXTERNAL`.
   163  	LaunchType pulumi.StringPtrInput `pulumi:"launchType"`
   164  	// Network configuration for the service. This parameter is required for task definitions that use the `awsvpc` network mode to receive their own Elastic Network Interface, and it is not supported for other network modes. See below.
   165  	NetworkConfiguration GetTaskExecutionNetworkConfigurationPtrInput `pulumi:"networkConfiguration"`
   166  	// A list of container overrides that specify the name of a container in the specified task definition and the overrides it should receive.
   167  	Overrides GetTaskExecutionOverridesPtrInput `pulumi:"overrides"`
   168  	// An array of placement constraint objects to use for the task. You can specify up to 10 constraints for each task. See below.
   169  	PlacementConstraints GetTaskExecutionPlacementConstraintArrayInput `pulumi:"placementConstraints"`
   170  	// The placement strategy objects to use for the task. You can specify a maximum of 5 strategy rules for each task. See below.
   171  	PlacementStrategies GetTaskExecutionPlacementStrategyArrayInput `pulumi:"placementStrategies"`
   172  	// The platform version the task uses. A platform version is only specified for tasks hosted on Fargate. If one isn't specified, the `LATEST` platform version is used.
   173  	PlatformVersion pulumi.StringPtrInput `pulumi:"platformVersion"`
   174  	// Specifies whether to propagate the tags from the task definition to the task. If no value is specified, the tags aren't propagated. An error will be received if you specify the `SERVICE` option when running a task. Valid values are `TASK_DEFINITION` or `NONE`.
   175  	PropagateTags pulumi.StringPtrInput `pulumi:"propagateTags"`
   176  	// The reference ID to use for the task.
   177  	ReferenceId pulumi.StringPtrInput `pulumi:"referenceId"`
   178  	// An optional tag specified when a task is started.
   179  	StartedBy pulumi.StringPtrInput `pulumi:"startedBy"`
   180  	// Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   181  	Tags pulumi.StringMapInput `pulumi:"tags"`
   182  	// The `family` and `revision` (`family:revision`) or full ARN of the task definition to run. If a revision isn't specified, the latest `ACTIVE` revision is used.
   183  	//
   184  	// The following arguments are optional:
   185  	TaskDefinition pulumi.StringInput `pulumi:"taskDefinition"`
   186  }
   187  
   188  func (GetTaskExecutionOutputArgs) ElementType() reflect.Type {
   189  	return reflect.TypeOf((*GetTaskExecutionArgs)(nil)).Elem()
   190  }
   191  
   192  // A collection of values returned by getTaskExecution.
   193  type GetTaskExecutionResultOutput struct{ *pulumi.OutputState }
   194  
   195  func (GetTaskExecutionResultOutput) ElementType() reflect.Type {
   196  	return reflect.TypeOf((*GetTaskExecutionResult)(nil)).Elem()
   197  }
   198  
   199  func (o GetTaskExecutionResultOutput) ToGetTaskExecutionResultOutput() GetTaskExecutionResultOutput {
   200  	return o
   201  }
   202  
   203  func (o GetTaskExecutionResultOutput) ToGetTaskExecutionResultOutputWithContext(ctx context.Context) GetTaskExecutionResultOutput {
   204  	return o
   205  }
   206  
   207  func (o GetTaskExecutionResultOutput) CapacityProviderStrategies() GetTaskExecutionCapacityProviderStrategyArrayOutput {
   208  	return o.ApplyT(func(v GetTaskExecutionResult) []GetTaskExecutionCapacityProviderStrategy {
   209  		return v.CapacityProviderStrategies
   210  	}).(GetTaskExecutionCapacityProviderStrategyArrayOutput)
   211  }
   212  
   213  func (o GetTaskExecutionResultOutput) ClientToken() pulumi.StringPtrOutput {
   214  	return o.ApplyT(func(v GetTaskExecutionResult) *string { return v.ClientToken }).(pulumi.StringPtrOutput)
   215  }
   216  
   217  func (o GetTaskExecutionResultOutput) Cluster() pulumi.StringOutput {
   218  	return o.ApplyT(func(v GetTaskExecutionResult) string { return v.Cluster }).(pulumi.StringOutput)
   219  }
   220  
   221  func (o GetTaskExecutionResultOutput) DesiredCount() pulumi.IntPtrOutput {
   222  	return o.ApplyT(func(v GetTaskExecutionResult) *int { return v.DesiredCount }).(pulumi.IntPtrOutput)
   223  }
   224  
   225  func (o GetTaskExecutionResultOutput) EnableEcsManagedTags() pulumi.BoolPtrOutput {
   226  	return o.ApplyT(func(v GetTaskExecutionResult) *bool { return v.EnableEcsManagedTags }).(pulumi.BoolPtrOutput)
   227  }
   228  
   229  func (o GetTaskExecutionResultOutput) EnableExecuteCommand() pulumi.BoolPtrOutput {
   230  	return o.ApplyT(func(v GetTaskExecutionResult) *bool { return v.EnableExecuteCommand }).(pulumi.BoolPtrOutput)
   231  }
   232  
   233  func (o GetTaskExecutionResultOutput) Group() pulumi.StringPtrOutput {
   234  	return o.ApplyT(func(v GetTaskExecutionResult) *string { return v.Group }).(pulumi.StringPtrOutput)
   235  }
   236  
   237  // The provider-assigned unique ID for this managed resource.
   238  func (o GetTaskExecutionResultOutput) Id() pulumi.StringOutput {
   239  	return o.ApplyT(func(v GetTaskExecutionResult) string { return v.Id }).(pulumi.StringOutput)
   240  }
   241  
   242  func (o GetTaskExecutionResultOutput) LaunchType() pulumi.StringPtrOutput {
   243  	return o.ApplyT(func(v GetTaskExecutionResult) *string { return v.LaunchType }).(pulumi.StringPtrOutput)
   244  }
   245  
   246  func (o GetTaskExecutionResultOutput) NetworkConfiguration() GetTaskExecutionNetworkConfigurationPtrOutput {
   247  	return o.ApplyT(func(v GetTaskExecutionResult) *GetTaskExecutionNetworkConfiguration { return v.NetworkConfiguration }).(GetTaskExecutionNetworkConfigurationPtrOutput)
   248  }
   249  
   250  func (o GetTaskExecutionResultOutput) Overrides() GetTaskExecutionOverridesPtrOutput {
   251  	return o.ApplyT(func(v GetTaskExecutionResult) *GetTaskExecutionOverrides { return v.Overrides }).(GetTaskExecutionOverridesPtrOutput)
   252  }
   253  
   254  func (o GetTaskExecutionResultOutput) PlacementConstraints() GetTaskExecutionPlacementConstraintArrayOutput {
   255  	return o.ApplyT(func(v GetTaskExecutionResult) []GetTaskExecutionPlacementConstraint { return v.PlacementConstraints }).(GetTaskExecutionPlacementConstraintArrayOutput)
   256  }
   257  
   258  func (o GetTaskExecutionResultOutput) PlacementStrategies() GetTaskExecutionPlacementStrategyArrayOutput {
   259  	return o.ApplyT(func(v GetTaskExecutionResult) []GetTaskExecutionPlacementStrategy { return v.PlacementStrategies }).(GetTaskExecutionPlacementStrategyArrayOutput)
   260  }
   261  
   262  func (o GetTaskExecutionResultOutput) PlatformVersion() pulumi.StringPtrOutput {
   263  	return o.ApplyT(func(v GetTaskExecutionResult) *string { return v.PlatformVersion }).(pulumi.StringPtrOutput)
   264  }
   265  
   266  func (o GetTaskExecutionResultOutput) PropagateTags() pulumi.StringPtrOutput {
   267  	return o.ApplyT(func(v GetTaskExecutionResult) *string { return v.PropagateTags }).(pulumi.StringPtrOutput)
   268  }
   269  
   270  func (o GetTaskExecutionResultOutput) ReferenceId() pulumi.StringPtrOutput {
   271  	return o.ApplyT(func(v GetTaskExecutionResult) *string { return v.ReferenceId }).(pulumi.StringPtrOutput)
   272  }
   273  
   274  func (o GetTaskExecutionResultOutput) StartedBy() pulumi.StringPtrOutput {
   275  	return o.ApplyT(func(v GetTaskExecutionResult) *string { return v.StartedBy }).(pulumi.StringPtrOutput)
   276  }
   277  
   278  func (o GetTaskExecutionResultOutput) Tags() pulumi.StringMapOutput {
   279  	return o.ApplyT(func(v GetTaskExecutionResult) map[string]string { return v.Tags }).(pulumi.StringMapOutput)
   280  }
   281  
   282  // A list of the provisioned task ARNs.
   283  func (o GetTaskExecutionResultOutput) TaskArns() pulumi.StringArrayOutput {
   284  	return o.ApplyT(func(v GetTaskExecutionResult) []string { return v.TaskArns }).(pulumi.StringArrayOutput)
   285  }
   286  
   287  func (o GetTaskExecutionResultOutput) TaskDefinition() pulumi.StringOutput {
   288  	return o.ApplyT(func(v GetTaskExecutionResult) string { return v.TaskDefinition }).(pulumi.StringOutput)
   289  }
   290  
   291  func init() {
   292  	pulumi.RegisterOutputType(GetTaskExecutionResultOutput{})
   293  }