agent-claw: automated task changes

This commit is contained in:
daniel
2026-05-06 18:55:16 -05:00
parent 38905bb1e9
commit 732b00fb66
8494 changed files with 2018127 additions and 4 deletions

View File

@@ -0,0 +1,4 @@
import type { CommonEcsRunTaskProps } from './run-ecs-task-base';
import './run-ecs-task-base';
import type * as ec2 from '../../../aws-ec2';
import * as ecs from '../../../aws-ecs';

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RunEcsEc2Task=void 0;const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var run_ecs_task_base_1=()=>{var tmp=require("./run-ecs-task-base");return run_ecs_task_base_1=()=>tmp,tmp},ecs=()=>{var tmp=require("../../../aws-ecs");return ecs=()=>tmp,tmp},core_1=()=>{var tmp=require("../../../core");return core_1=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp};class RunEcsEc2Task extends run_ecs_task_base_1().EcsRunTaskBase{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_stepfunctions_tasks.RunEcsEc2Task",version:"2.252.0"};constructor(props){if(!props.taskDefinition.isEc2Compatible)throw new(core_1()).UnscopedValidationError((0,literal_string_1().lit)`SuppliedTaskdefinitionConfiguredCompatibility`,"Supplied TaskDefinition is not configured for compatibility with EC2");if(!props.cluster.hasEc2Capacity)throw new(core_1()).UnscopedValidationError((0,literal_string_1().lit)`ClusterServiceNeedsCapacity`,"Cluster for this service needs Ec2 capacity. Call addXxxCapacity() on the cluster.");if(!props.taskDefinition.defaultContainer)throw new(core_1()).UnscopedValidationError((0,literal_string_1().lit)`TaskdefinitionLeastEssentialContainer`,"A TaskDefinition must have at least one essential container");super({...props,parameters:{LaunchType:"EC2",PlacementConstraints:noEmpty(flatten((props.placementConstraints||[]).map(c=>c.toJson().map(uppercaseKeys)))),PlacementStrategy:noEmpty(flatten((props.placementStrategies||[]).map(c=>c.toJson().map(uppercaseKeys))))}}),props.taskDefinition.networkMode===ecs().NetworkMode.AWS_VPC?this.configureAwsVpcNetworking(props.cluster.vpc,void 0,props.subnets,props.securityGroup):(validateNoNetworkingProps(props),this.connections.addSecurityGroup(...props.cluster.connections.securityGroups))}}exports.RunEcsEc2Task=RunEcsEc2Task;function validateNoNetworkingProps(props){if(props.subnets!==void 0||props.securityGroup!==void 0)throw new(core_1()).UnscopedValidationError((0,literal_string_1().lit)`VpcplacementSecuritygroupOnlyUsed`,"vpcPlacement and securityGroup can only be used in AwsVpc networking mode")}function uppercaseKeys(obj){const ret={};for(const key of Object.keys(obj))ret[key.slice(0,1).toUpperCase()+key.slice(1)]=obj[key];return ret}function flatten(xs){return Array.prototype.concat([],...xs)}function noEmpty(xs){if(xs.length!==0)return xs}

View File

@@ -0,0 +1,4 @@
import type { CommonEcsRunTaskProps } from './run-ecs-task-base';
import './run-ecs-task-base';
import type * as ec2 from '../../../aws-ec2';
import type * as ecs from '../../../aws-ecs';

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RunEcsFargateTask=void 0;const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var run_ecs_task_base_1=()=>{var tmp=require("./run-ecs-task-base");return run_ecs_task_base_1=()=>tmp,tmp},core_1=()=>{var tmp=require("../../../core");return core_1=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp};class RunEcsFargateTask extends run_ecs_task_base_1().EcsRunTaskBase{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_stepfunctions_tasks.RunEcsFargateTask",version:"2.252.0"};constructor(props){if(!props.taskDefinition.isFargateCompatible)throw new(core_1()).UnscopedValidationError((0,literal_string_1().lit)`SuppliedTaskdefinitionConfiguredCompatibility`,"Supplied TaskDefinition is not configured for compatibility with Fargate");if(!props.taskDefinition.defaultContainer)throw new(core_1()).UnscopedValidationError((0,literal_string_1().lit)`TaskdefinitionLeastEssentialContainer`,"A TaskDefinition must have at least one essential container");super({...props,parameters:{LaunchType:"FARGATE"}}),this.configureAwsVpcNetworking(props.cluster.vpc,props.assignPublicIp,props.subnets,props.securityGroup)}}exports.RunEcsFargateTask=RunEcsFargateTask;

View File

@@ -0,0 +1,61 @@
import type { ContainerDefinition } from '../../../aws-ecs';
/**
* A list of container overrides that specify the name of a container
* and the overrides it should receive.
*/
export interface ContainerOverride {
/**
* Name of the container inside the task definition
*/
readonly containerDefinition: ContainerDefinition;
/**
* Command to run inside the container
*
* @default - Default command from the Docker image or the task definition
*/
readonly command?: string[];
/**
* The environment variables to send to the container.
*
* You can add new environment variables, which are added to the container at launch,
* or you can override the existing environment variables from the Docker image or the task definition.
*
* @default - The existing environment variables from the Docker image or the task definition
*/
readonly environment?: TaskEnvironmentVariable[];
/**
* The number of cpu units reserved for the container
*
* @default - The default value from the task definition.
*/
readonly cpu?: number;
/**
* The hard limit (in MiB) of memory to present to the container
*
* @default - The default value from the task definition.
*/
readonly memoryLimit?: number;
/**
* The soft limit (in MiB) of memory to reserve for the container
*
* @default - The default value from the task definition.
*/
readonly memoryReservation?: number;
}
/**
* An environment variable to be set in the container run as a task
*/
export interface TaskEnvironmentVariable {
/**
* Name for the environment variable
*
* Use `JsonPath` class's static methods to specify name from a JSON path.
*/
readonly name: string;
/**
* Value of the environment variable
*
* Use `JsonPath` class's static methods to specify value from a JSON path.
*/
readonly value: string;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});

View File

@@ -0,0 +1,39 @@
import type { ContainerOverride } from './run-ecs-task-base-types';
import * as ec2 from '../../../aws-ec2';
import type * as ecs from '../../../aws-ecs';
import * as sfn from '../../../aws-stepfunctions';
/**
* Basic properties for ECS Tasks
*/
export interface CommonEcsRunTaskProps {
/**
* The topic to run the task on
*/
readonly cluster: ecs.ICluster;
/**
* Task Definition used for running tasks in the service.
*
* Note: this must be TaskDefinition, and not ITaskDefinition,
* as it requires properties that are not known for imported task definitions
* If you want to run a RunTask with an imported task definition,
* consider using CustomState
*/
readonly taskDefinition: ecs.TaskDefinition;
/**
* Container setting overrides
*
* Key is the name of the container to override, value is the
* values you want to override.
*
* @default - No overrides
*/
readonly containerOverrides?: ContainerOverride[];
/**
* The service integration pattern indicates different ways to call RunTask in ECS.
*
* The valid value for Lambda is FIRE_AND_FORGET, SYNC and WAIT_FOR_TASK_TOKEN.
*
* @default FIRE_AND_FORGET
*/
readonly integrationPattern?: sfn.ServiceIntegrationPattern;
}

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EcsRunTaskBase=void 0;const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var ec2=()=>{var tmp=require("../../../aws-ec2");return ec2=()=>tmp,tmp},iam=()=>{var tmp=require("../../../aws-iam");return iam=()=>tmp,tmp},sfn=()=>{var tmp=require("../../../aws-stepfunctions");return sfn=()=>tmp,tmp},cdk=()=>{var tmp=require("../../../core");return cdk=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp},resource_arn_suffix_1=()=>{var tmp=require("../resource-arn-suffix");return resource_arn_suffix_1=()=>tmp,tmp};class EcsRunTaskBase{props;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_stepfunctions_tasks.EcsRunTaskBase",version:"2.252.0"};connections=new(ec2()).Connections;securityGroup;networkConfiguration;integrationPattern;constructor(props){if(this.props=props,this.integrationPattern=props.integrationPattern||sfn().ServiceIntegrationPattern.FIRE_AND_FORGET,![sfn().ServiceIntegrationPattern.FIRE_AND_FORGET,sfn().ServiceIntegrationPattern.WAIT_FOR_TASK_TOKEN,sfn().ServiceIntegrationPattern.SYNC].includes(this.integrationPattern))throw new(cdk()).UnscopedValidationError((0,literal_string_1().lit)`InvalidServiceIntegrationPattern`,`Invalid Service Integration Pattern: ${this.integrationPattern} is not supported to call ECS.`);if(this.integrationPattern===sfn().ServiceIntegrationPattern.WAIT_FOR_TASK_TOKEN&&!sfn().FieldUtils.containsTaskToken(props.containerOverrides?.map(override=>override.environment)))throw new(cdk()).UnscopedValidationError((0,literal_string_1().lit)`TaskTokenRequired`,"Task Token is required in at least one `containerOverrides.environment` for callback. Use JsonPath.taskToken to set the token.");for(const override of this.props.containerOverrides||[]){const name=override.containerDefinition.containerName;if(!cdk().Token.isUnresolved(name)&&!this.props.taskDefinition.node.tryFindChild(name))throw new(cdk()).UnscopedValidationError((0,literal_string_1().lit)`OverridesMentionContainerName`,`Overrides mention container with name '${name}', but no such container in task definition`)}}bind(task){return this.networkConfiguration!==void 0&&(this.securityGroup===void 0&&(this.securityGroup=new(ec2()).SecurityGroup(task,"SecurityGroup",{vpc:this.props.cluster.vpc})),this.connections.addSecurityGroup(this.securityGroup)),{resourceArn:(0,resource_arn_suffix_1().getResourceArn)("ecs","runTask",this.integrationPattern),parameters:{Cluster:this.props.cluster.clusterArn,TaskDefinition:this.props.taskDefinition.taskDefinitionArn,NetworkConfiguration:this.networkConfiguration,Overrides:renderOverrides(this.props.containerOverrides),...this.props.parameters},policyStatements:this.makePolicyStatements(task)}}configureAwsVpcNetworking(vpc,assignPublicIp,subnetSelection,securityGroup){subnetSelection===void 0&&(subnetSelection={subnetType:assignPublicIp?ec2().SubnetType.PUBLIC:ec2().SubnetType.PRIVATE_WITH_EGRESS}),this.securityGroup=securityGroup,this.networkConfiguration={AwsvpcConfiguration:{AssignPublicIp:assignPublicIp!==void 0?assignPublicIp?"ENABLED":"DISABLED":void 0,Subnets:vpc.selectSubnets(subnetSelection).subnetIds,SecurityGroups:cdk().Lazy.list({produce:()=>[this.securityGroup.securityGroupId]})}}}makePolicyStatements(task){const stack=cdk().Stack.of(task),policyStatements=[new(iam()).PolicyStatement({actions:["ecs:RunTask"],resources:[this.props.taskDefinition.taskDefinitionArn]}),new(iam()).PolicyStatement({actions:["ecs:StopTask","ecs:DescribeTasks"],resources:["*"]}),new(iam()).PolicyStatement({actions:["iam:PassRole"],resources:cdk().Lazy.list({produce:()=>this.taskExecutionRoles().map(r=>r.roleArn)})})];return this.integrationPattern===sfn().ServiceIntegrationPattern.SYNC&&policyStatements.push(new(iam()).PolicyStatement({actions:["events:PutTargets","events:PutRule","events:DescribeRule"],resources:[stack.formatArn({service:"events",resource:"rule",resourceName:"StepFunctionsGetEventsForECSTaskRule"})]})),policyStatements}taskExecutionRoles(){const ret=new Array;return ret.push(this.props.taskDefinition.taskRole),this.props.taskDefinition.executionRole&&ret.push(this.props.taskDefinition.executionRole),ret}}exports.EcsRunTaskBase=EcsRunTaskBase;function renderOverrides(containerOverrides){if(!containerOverrides)return;const ret=new Array;for(const override of containerOverrides)ret.push({Name:override.containerDefinition.containerName,Command:override.command,Cpu:override.cpu,Memory:override.memoryLimit,MemoryReservation:override.memoryReservation,Environment:override.environment&&override.environment.map(e=>({Name:e.name,Value:e.value}))});return{ContainerOverrides:ret}}

View File

@@ -0,0 +1,299 @@
import type { Construct } from 'constructs';
import type { ContainerOverride } from '..';
import * as ec2 from '../../../aws-ec2';
import * as ecs from '../../../aws-ecs';
import * as iam from '../../../aws-iam';
import * as sfn from '../../../aws-stepfunctions';
interface EcsRunTaskOptions {
/**
* The ECS cluster to run the task on
*/
readonly cluster: ecs.ICluster;
/**
* [disable-awslint:ref-via-interface]
* Task Definition used for running tasks in the service.
*
* Note: this must be TaskDefinition, and not ITaskDefinition,
* as it requires properties that are not known for imported task definitions
* If you want to run a RunTask with an imported task definition,
* consider using CustomState
*/
readonly taskDefinition: ecs.TaskDefinition;
/**
* The revision number of ECS task definition family
*
* @default - '$latest'
*/
readonly revisionNumber?: number;
/**
* Container setting overrides
*
* Specify the container to use and the overrides to apply.
*
* @default - No overrides
*/
readonly containerOverrides?: ContainerOverride[];
/**
* Subnets to place the task's ENIs
*
* @default - Public subnets if assignPublicIp is set. Private subnets otherwise.
*/
readonly subnets?: ec2.SubnetSelection;
/**
* Existing security groups to use for the tasks
*
* @default - A new security group is created
*/
readonly securityGroups?: ec2.ISecurityGroup[];
/**
* Assign public IP addresses to each task
*
* @default false
*/
readonly assignPublicIp?: boolean;
/**
* An Amazon ECS launch type determines the type of infrastructure on which your
* tasks and services are hosted.
*
* @see https://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_types.html
*/
readonly launchTarget: IEcsLaunchTarget;
/**
* Specifies whether to propagate the tags from the task definition to the task.
* An error will be received if you specify the SERVICE option when running a task.
*
* @see https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_RunTask.html#ECS-RunTask-request-propagateTags
*
* @default - No tags are propagated.
*/
readonly propagatedTagSource?: ecs.PropagatedTagSource;
/**
* Whether ECS Exec should be enabled
*
* @see https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_RunTask.html#ECS-RunTask-request-enableExecuteCommand
*
* @default false
*/
readonly enableExecuteCommand?: boolean;
/**
* Cpu setting override
* @see https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_TaskOverride.html
* @default - No override
*/
readonly cpu?: string;
/**
* Memory setting override
* @see https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_TaskOverride.html
* @default - No override
*/
readonly memoryMiB?: string;
}
/**
* An Amazon ECS launch type determines the type of infrastructure on which your tasks and services are hosted.
* @see https://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_types.html
*/
export interface IEcsLaunchTarget {
/**
* called when the ECS launch target is configured on RunTask
*/
bind(task: EcsRunTask, launchTargetOptions: LaunchTargetBindOptions): EcsLaunchTargetConfig;
}
/**
* Options for binding a launch target to an ECS run job task
*/
export interface LaunchTargetBindOptions {
/**
* Task definition to run Docker containers in Amazon ECS
*/
readonly taskDefinition: ecs.ITaskDefinition;
/**
* A regional grouping of one or more container instances on which you can run
* tasks and services.
*
* @default - No cluster
*/
readonly cluster?: ecs.ICluster;
}
/**
* Configuration options for the ECS launch type
*/
export interface EcsLaunchTargetConfig {
/**
* Additional parameters to pass to the base task
*
* @default - No additional parameters passed
*/
readonly parameters?: {
[key: string]: any;
};
}
/**
* Properties to define an ECS service
*/
export interface EcsFargateLaunchTargetOptions {
/**
* Refers to a specific runtime environment for Fargate task infrastructure.
* Fargate platform version is a combination of the kernel and container runtime versions.
*
* @see https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform_versions.html
*/
readonly platformVersion: ecs.FargatePlatformVersion;
/**
* The capacity provider options to use for the task.
*
* This property allows you to set the capacity provider strategy for the task.
*
* If you want to set the capacity provider strategy for the task, specify
* `CapacityProviderOptions.custom()`. This is required to use the FARGATE_SPOT
* capacity provider.
*
* If you want to use the cluster's default capacity provider strategy, specify
* `CapacityProviderOptions.default()`.
*
* @default - 'FARGATE' LaunchType running tasks on AWS Fargate On-Demand
* infrastructure is used without the capacity provider strategy.
*/
readonly capacityProviderOptions?: CapacityProviderOptions;
}
/**
* Options to run an ECS task on EC2 in StepFunctions and ECS
*/
export interface EcsEc2LaunchTargetOptions {
/**
* Placement constraints
*
* @default - None
*/
readonly placementConstraints?: ecs.PlacementConstraint[];
/**
* Placement strategies
*
* @default - None
*/
readonly placementStrategies?: ecs.PlacementStrategy[];
/**
* The capacity provider options to use for the task.
*
* This property allows you to set the capacity provider strategy for the task.
*
* If you want to set the capacity provider strategy for the task, specify
* `CapacityProviderOptions.custom()`.
*
* If you want to use the cluster's default capacity provider strategy, specify
* `CapacityProviderOptions.default()`.
*
* @default - 'EC2' LaunchType running tasks on Amazon EC2 instances registered to
* your cluster is used without the capacity provider strategy.
*/
readonly capacityProviderOptions?: CapacityProviderOptions;
}
/**
* Capacity provider options
*/
export declare class CapacityProviderOptions {
private readonly capacityProviderStrategy;
/**
* Use a custom capacity provider strategy.
*
* You can specify between 1 and 20 capacity providers.
*
* @param capacityProviderStrategy The capacity provider strategy to use for the task.
*/
static custom(capacityProviderStrategy: ecs.CapacityProviderStrategy[]): CapacityProviderOptions;
/**
* Use the cluster's default capacity provider strategy.
*/
static default(): CapacityProviderOptions;
private constructor();
/**
* @internal
*/
_bind(): ecs.CapacityProviderStrategy[];
}
/**
* Configuration for running an ECS task on Fargate
*
* @see https://docs.aws.amazon.com/AmazonECS/latest/userguide/launch_types.html#launch-type-fargate
*/
export declare class EcsFargateLaunchTarget implements IEcsLaunchTarget {
private readonly options?;
constructor(options?: EcsFargateLaunchTargetOptions | undefined);
/**
* Called when the Fargate launch type configured on RunTask
*/
bind(task: EcsRunTask, launchTargetOptions: LaunchTargetBindOptions): EcsLaunchTargetConfig;
}
/**
* Configuration for running an ECS task on EC2
*
* @see https://docs.aws.amazon.com/AmazonECS/latest/userguide/launch_types.html#launch-type-ec2
*/
export declare class EcsEc2LaunchTarget implements IEcsLaunchTarget {
private readonly options?;
constructor(options?: EcsEc2LaunchTargetOptions | undefined);
/**
* Called when the EC2 launch type is configured on RunTask
*/
bind(task: EcsRunTask, launchTargetOptions: LaunchTargetBindOptions): EcsLaunchTargetConfig;
}
/**
* Properties for ECS Tasks using JSONPath
*/
export interface EcsRunTaskJsonPathProps extends sfn.TaskStateJsonPathBaseProps, EcsRunTaskOptions {
}
/**
* Properties for ECS Tasks using JSONata
*/
export interface EcsRunTaskJsonataProps extends sfn.TaskStateJsonataBaseProps, EcsRunTaskOptions {
}
/**
* Properties for ECS Tasks
*/
export interface EcsRunTaskProps extends sfn.TaskStateBaseProps, EcsRunTaskOptions {
}
/**
* Run a Task on ECS or Fargate
*/
export declare class EcsRunTask extends sfn.TaskStateBase implements ec2.IConnectable {
private readonly props;
/**
* Uniquely identifies this class.
*/
static readonly PROPERTY_INJECTION_ID: string;
/**
* Run a Task that using JSONPath on ECS or Fargate
*/
static jsonPath(scope: Construct, id: string, props: EcsRunTaskJsonPathProps): EcsRunTask;
/**
* Run a Task that using JSONata on ECS or Fargate
*/
static jsonata(scope: Construct, id: string, props: EcsRunTaskJsonataProps): EcsRunTask;
private static readonly SUPPORTED_INTEGRATION_PATTERNS;
/**
* Manage allowed network traffic for this service
*/
readonly connections: ec2.Connections;
protected readonly taskMetrics?: sfn.TaskMetricsConfig;
protected readonly taskPolicies?: iam.PolicyStatement[];
private securityGroups;
private networkConfiguration?;
private readonly integrationPattern;
constructor(scope: Construct, id: string, props: EcsRunTaskProps);
/**
* @internal
*/
protected _renderTask(topLevelQueryLanguage?: sfn.QueryLanguage): any;
private configureAwsVpcNetworking;
private validateNoNetworkingProps;
private makePolicyStatements;
private getTaskDefinitionArn;
/**
* Returns the ARN of the task definition family by removing the
* revision from the task definition ARN
* Before - arn:aws:ecs:us-west-2:123456789012:task-definition/hello_world:8
* After - arn:aws:ecs:us-west-2:123456789012:task-definition/hello_world
*/
private getTaskDefinitionFamilyArn;
private taskExecutionRoles;
}
export {};

File diff suppressed because one or more lines are too long