1

My requirement is, need to launch an AWS EC2 Instance through REST API while TFS running. For that I need to register the API in TFS as Generic Service Endpoint.

I am not aware how to add the API endpoint because the endpoint contains many header values and signatures. I hope we can pass the Signature in token. But what need to pass for UserName? enter image description here Could anyone know how to register the AWS REST API in TFS service Endpoint.?

Prakash26790
  • 727
  • 9
  • 29
  • You need to launch an AWS EC2 Instance through REST API while TFS running. How would you do this? Are you going to use [Amazon EC2 API](http://docs.aws.amazon.com/AWSEC2/latest/APIReference/Welcome.html) Besides, what's the detail mean of `while TFS running` ? Through a build or just mean when you launch TFS server? – PatrickLu-MSFT Aug 15 '17 at 14:22
  • While TFS running means, In the pipeline before running the deployment stage need to provision the Instance. For that I need to launch EC2 Instance by using the REST API. – Prakash26790 Aug 15 '17 at 15:37
  • alltej is right, you could use a powershell script to authenticate with AWS API to launch a EC2 instance and invoke the REST API from your Build pipeline in TFS. – PatrickLu-MSFT Aug 17 '17 at 08:30
  • 1
    @alltej and Patrick, I can use but I need to pass the credentials. I should not pass/store the credentials. So only I am preferring REST API. – Prakash26790 Aug 17 '17 at 10:18
  • It's easy to overcome, you could use hidden variable during TFS build/Release, at build time value of variable is correctly applied, and in logs this value appears as "*****". Add related sample for your reference: https://www.benday.com/2016/06/06/handling-passwords-in-visual-studio-tfs-releases/ & https://stackoverflow.com/questions/36997494/vsts-pass-build-variables-into-powershell-script-task – PatrickLu-MSFT Aug 17 '17 at 14:46
  • Thanks for new idea. But I have one doubt. We can use that variable in TFS. But If we do echo with variable, will it print the original value or encrypted one? If it prints encrypted value means while passing the variable as argument, how the code utilize the encrypted value? – Prakash26790 Aug 17 '17 at 17:37
  • It prints encrypted,the values of hidden (secret) variables are stored securely on the server and cannot be viewed by users after they are saved. During a deployment, the Release Management service decrypts these values when referenced by the tasks and passes them to the agent over a secure HTTPS channel. For build the variable replacement is also done on the inputs on the tasks, more details please refer the discussion in this link: [Use hidden / secret variables](https://github.com/Microsoft/vsts-tasks/issues/388) – PatrickLu-MSFT Aug 18 '17 at 17:18
  • Hi Prakash26790 , have you figure out the solution, any update on this? If my reply helped or gave a right direction. Appreciate for a vote or [mark it as an answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) which will also helps others in the community. – PatrickLu-MSFT Aug 25 '17 at 02:20
  • not yet @Patrick-MSFT – Prakash26790 Sep 29 '17 at 07:44

2 Answers2

0

It's not able to register aws ec2 instance API in TFS Generic Service Endpoint.

You could use a powershell script to authenticate with AWS API to launch a EC2 instance and invoke the REST API from your Build Pipeline.


Besides, you could use AWS Tools for Microsoft Visual Studio Team Services.

This tool include a new service endpoint type, AWS, to supply AWS credentials to the tasks at runtime.

It will create an AWS Credentials Connection. Select the AWS endpoint type and provide the following parameters:

  • A name used to refer to the credentials when configuring tasks that require AWS credentials
  • AWS Access Key ID
  • AWS Secret Access Key

enter image description here

After an AWS subscription has be linked to Team Foundation Server, you could use the task deploy to Amazon EC2 with AWS CodeDeploy.

Note: Minimum supported environments

  • Visual Studio Team Services
  • Team Foundation Server 2015 Update 3 (or higher)
PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
0

You should do this task via powershell script and just add a powershell step in the TFS build/release workflow. You have flexibility to run it via powershell command line without the TFS web UI. Also the script is portable. It can be invoked in TFS,Jenkins, etc.

alltej
  • 6,787
  • 10
  • 46
  • 87