Black_Pulse
Black_Pulse

Reputation: 55

Running an ECS task from .net desktop application

I am writing a simple desktop application using C# on Visual Studio. I am using the AWSSDK.Core and AWSSDK.ECS nuget packages. The access credentials are provided through ADFS CLI method. Since there is not much documentation regarding the .net SDK for ECS, I need some help regarding the Network Configuration parameters required to start a Fargate task using an existing task definition and cluster.

I have tried the example code provided in the AWS .net SDK documentation.

var response = client.RunTask(new RunTaskRequest 
{
    Cluster = "default",
    TaskDefinition = "sleep360:1"
});

List<Task> tasks = response.Tasks;

I would like to start a Fargate task from this desktop application with the Subnets and Security Groups defined within the AWSVPCConfiguration.

Upvotes: 0

Views: 1458

Answers (1)

Aimless
Aimless

Reputation: 36

I think it should look something like this:

var response = client.RunTask(new RunTaskRequest 
{
    Cluster = "default",
    TaskDefinition = "sleep360:1"
    PlatformVersion = "LATEST",
    LaunchType = "FARGATE",
    NetworkConfiguration = new NetworkConfiguration
    {
        AwsvpcConfiguration = new AwsVpcConfiguration
        {
            Subnets = new List<string>() { "subnet-XXXXXXXX" },
            SecurityGroups = new List<string>() { "sg-XXXXXXXXXXXXXXXXX" },
            AssignPublicIp = AssignPublicIp.ENABLED
        }
    }
});

Upvotes: 2

Related Questions