Example #1
0
// NewRsaService creates a new SSM service instance.
func NewRsaService(serverId string, region string, encodedPrivateKey string) RsaSignedService {
	awsConfig := util.AwsConfig()

	awsConfig.Region = &region
	awsConfig.Credentials = credentials.NewStaticCredentials(serverId, encodedPrivateKey, "")

	// Create a session to share service client config and handlers with
	ssmSess := session.New(awsConfig)

	// Clear existing singers
	ssmSess.Handlers.Sign.Clear()
	// Add custom signer to session, will be used by any service created with this session
	ssmSess.Handlers.Sign.PushBack(v4.SignRsa)

	ssmService := ssm.New(ssmSess)
	return &sdkService{sdk: ssmService}
}
Example #2
0
// NewAnonymousService creates a new SSM service instance.
func NewAnonymousService(region string) AnonymousService {
	log.SetFlags(0)
	awsConfig := util.AwsConfig().WithLogLevel(aws.LogOff)

	awsConfig.Region = &region
	awsConfig.Credentials = credentials.AnonymousCredentials

	//parse appConfig override to get ssm endpoint if there is any
	appConfig, err := appconfig.Config(true)
	if err == nil {
		if appConfig.Ssm.Endpoint != "" {
			awsConfig.Endpoint = &appConfig.Ssm.Endpoint
		}
	} else {
		log.Printf("encountered error while loading appconfig - %s", err)
	}

	// Create a session to share service client config and handlers with
	ssmSess := session.New(awsConfig)

	ssmService := ssm.New(ssmSess)
	return &sdkService{sdk: ssmService}
}