AWS EC2 LaunchTemplate Fails With Attached Network Interface (amazon.sync.action.RunWithTags)

We are trying to start an EC2 instance from a template that uses an attached network interface.

The EC2 creation template fails at the AWS EC2 api call RunInstance:

[2023-04-26 09:50:23,404]   WARN [ty-BuildAgent-1] - amazon.sync.action.RunWithTags - got an error during starting and instance: com.amazonaws.services.ec2.model.AmazonEC2Exception: You cannot specify tags for network interfaces if there are no network interfaces being created by the request. (Service: AmazonEC2; Status Code: 400; Error Code: InvalidParameterValue; Request ID: e2bc701d-8957-4c19-b43e-3b8440e5959c; Proxy: null)
[2023-04-26 09:50:23,404]  DEBUG [ty-BuildAgent-1] - amazon.sync.action.RunWithTags - got an error during starting and instance
com.amazonaws.services.ec2.model.AmazonEC2Exception: You cannot specify tags for network interfaces if there are no network interfaces being created by the request. (Service: AmazonEC2; Status Code: 400; Error Code: InvalidParameterValue; Request ID: e2bc701d-8957-4c19-b43e-3b8440e5959c; Proxy: null)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1862) ~[?:?]
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleServiceErrorResponse(AmazonHttpClient.java:1415) ~[?:?]
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1384) ~[?:?]
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1154) ~[?:?]
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:811) ~[?:?]
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:779) ~[?:?]
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:753) ~[?:?]
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:713) ~[?:?]
    at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:695) ~[?:?]
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:559) ~[?:?]
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:539) ~[?:?]
    at com.amazonaws.services.ec2.AmazonEC2Client.doInvoke(AmazonEC2Client.java:31244) ~[?:?]
    at com.amazonaws.services.ec2.AmazonEC2Client.invoke(AmazonEC2Client.java:31211) ~[?:?]
    at com.amazonaws.services.ec2.AmazonEC2Client.invoke(AmazonEC2Client.java:31200) ~[?:?]
    at com.amazonaws.services.ec2.AmazonEC2Client.executeRunInstances(AmazonEC2Client.java:29959) ~[?:?]
    at com.amazonaws.services.ec2.AmazonEC2Client.runInstances(AmazonEC2Client.java:29928) ~[?:?]
    at jetbrains.buildServer.clouds.amazon.sync.action.RunWithTags.runWithTags(RunWithTags.java:43) ~[?:?]
    at jetbrains.buildServer.clouds.amazon.sync.action.AbstractStartInstanceFromSourceAction.apply(AbstractStartInstanceFromSourceAction.java:98) ~[?:?]
    at jetbrains.buildServer.clouds.amazon.sync.action.AbstractStartInstanceFromSourceAction.apply(AbstractStartInstanceFromSourceAction.java:26) ~[?:?]
    at jetbrains.buildServer.clouds.amazon.sync.AmazonConnectionImpl.lambda$catchEC2Exception$0(AmazonConnectionImpl.java:126) ~[?:?]
    at jetbrains.buildServer.clouds.amazon.sync.AmazonConnectionImpl.baseOperation(AmazonConnectionImpl.java:139) ~[?:?]
    at jetbrains.buildServer.clouds.amazon.sync.AmazonConnectionImpl.catchEC2Exception(AmazonConnectionImpl.java:126) ~[?:?]
    at jetbrains.buildServer.clouds.amazon.sync.SyncClientBase.catchEC2Exception(SyncClientBase.java:26) ~[?:?]
    at jetbrains.buildServer.clouds.amazon.sync.SyncClientBase.catchEC2Exception(SyncClientBase.java:20) ~[?:?]
    at jetbrains.buildServer.clouds.amazon.sync.AmazonSyncClientImpl.runInstanceFromLaunchTemplate(AmazonSyncClientImpl.java:245) ~[?:?]
    at jetbrains.buildServer.clouds.amazon.image.AmazonLaunchTemplateImpl.startInstanceRaw(AmazonLaunchTemplateImpl.java:44) ~[?:?]
    at jetbrains.buildServer.clouds.amazon.image.MultiInstancesImageImpl.lambda$startNewInstance$0(MultiInstancesImageImpl.java:66) ~[?:?]
    at jetbrains.buildServer.clouds.amazon.async.AmazonAsyncClientImpl$1.run(AmazonAsyncClientImpl.java:104) ~[?:?]
    at jetbrains.buildServer.util.NamedThreadFactory.executeWithNewThreadName(NamedThreadFactory.java:76) ~[common-api.jar:117072]
    at jetbrains.buildServer.util.ExceptionUtil$1.run(ExceptionUtil.java:42) ~[common-api.jar:117072]
  at java.lang.Thread.run(Thread.java:829) ~[?:?]

Is there any way to use a pre-defined network interface with an EC2 launch template or AMI?

The use case is that we need a repeatable MAC address for our build agents.

1
5 comments
Hi @Brad.Kreager,

Are you able to successfully use the template outside TeamCity?

Please provide screenshots of the configuration you have in TeamCity. Feel free to mask any sensitive information.
0

Hi Mikhail,

The problem occurs when a pre-existing network interface is added to the template:

The network interface was previously created through the network interface page and defines the subnet/security policies that are be used by the network interface.

We have AMI image selected for a Windows Server instance to be created:

Everything else in the template is the default settings.

This template can be launched through the EC2 console by going to instances > Launch from template

When attempting the start an instance with the template from TeamCity, we receive the exception about not being able to specify tags for the network interface.

 

Thanks

 

0
Hi Brad,

Apologies for the delay. Thank you for the screenshots from the AWS, they may help as well. But I'd like to see how you have it configured on the TeamCity side. This looks like a bug, I'll try to reproduce it and get back to you.
0

Hi Mikhail Efremov , has there been any update to this? I'm running into the exact same issue on TeamCity Professional 2024.12 (build 174331). If there's anything I can provide to assist, let me know.

Thanks!

0
Hi Nicolas,

I'm terribly sorry for the delay. This thread somehow slipped under my radar.

I reproduced the issue and created a bug report: https://youtrack.jetbrains.com/issue/TW-91909/EC2-Cloud-Profile-Cannot-use-Launch-Templates-with-attached-Network-Interfaces. Feel free to vote for the request, leave comments, and subscribe to the updates. See https://intellij-support.jetbrains.com/hc/articles/207241135 if you are still getting familiar with YouTrack.

Any other questions, just let me know.
1

Please sign in to leave a comment.