Octopus Deploy Documentation

Create an AWS account

Last updated

This script provides an example of how to programmatically create an AWS account.


Provide values for:

  • Octopus URL
  • Octopus API Key
  • Octopus Space ID
  • AWS account key
  • AWS secret key


package main

import (


func main() {
	octopusURL := os.Args[1]
	space := os.Args[2]
	name := os.Args[3]
	accessKey := os.Args[4]

	// Pass in the API key securely
	fmt.Println("Enter Password Securely: ")
	apiKey, err := terminal.ReadPassword(0)

	if err != nil {

	APIKey := string(apiKey)

	// Pass in the Azure Client password/secret securely
	fmt.Println("Enter AWS Secret Key Securely: ")
	clientPassword, err := terminal.ReadPassword(0)

	if err != nil {
	password := string(clientPassword)
	awsSecretKey := model.NewSensitiveValue(password)

	// Call both functions from the main function
	octopusAuth(octopusURL, APIKey, space)
	CreateAWSAccount(octopusURL, APIKey, space, name, accessKey, awsSecretKey)

func octopusAuth(octopusURL, APIKey, space string) *client.Client {
	apiClient, err := client.NewClient(nil, octopusURL, APIKey, space)
	if err != nil {

	return apiClient

func CreateAWSAccount(octopusURL string, APIKey string, space string, name string, accessKey string, awsSecretKey model.SensitiveValue) *model.Account {
	apiClient := octopusAuth(octopusURL, APIKey, space)
	Account, err := model.NewAwsServicePrincipalAccount(name, accessKey, awsSecretKey)

	if err != nil {


	return Account

Need support? We're here to help.