func (secret *SSMSecretResource) Create() error {

	// To fail fast, check execution role first
	executionCredentials, ok := secret.credentialsManager.GetTaskCredentials(secret.getExecutionCredentialsID())
	if !ok {
		// No need to log here. managedTask.applyResourceState already does that
		err := errors.New("ssm secret resource: unable to find execution role credentials")
		secret.setTerminalReason(err.Error())
		return err
	}
	iamCredentials := executionCredentials.GetIAMRoleCredentials()

	var wg sync.WaitGroup

	// Get the maximum number of errors can be returned, which will be one error per goroutine
	chanLen := secret.getGoRoutineMaxNum()
	errorEvents := make(chan error, chanLen)

	seelog.Infof("ssm secret resource: retrieving secrets for containers in task: [%s]", secret.taskARN)
	secret.secretData = make(map[string]string)

	for region, secrets := range secret.getRequiredSecrets() {
		wg.Add(1)
		// Spin up goroutine each region to speed up processing time
		go secret.retrieveSSMSecretValuesByRegion(region, secrets, iamCredentials, &wg, errorEvents)
	}

	wg.Wait()

	// Get the first error returned and set as terminal reason
	select {
	case err := <-errorEvents:
		secret.setTerminalReason(err.Error())
		return err
	default:
		return nil
	}
}
func (secret *SSMSecretResource) Create() error {

	// To fail fast, check execution role first
	executionCredentials, ok := secret.credentialsManager.GetTaskCredentials(secret.getExecutionCredentialsID())
	if !ok {
		// No need to log here. managedTask.applyResourceState already does that
		err := errors.New("ssm secret resource: unable to find execution role credentials")
		secret.setTerminalReason(err.Error())
		return err
	}
	iamCredentials := executionCredentials.GetIAMRoleCredentials()

	var wg sync.WaitGroup

	// Get the maximum number of errors can be returned, which will be one error per goroutine
	chanLen := secret.getGoRoutineMaxNum()
	errorEvents := make(chan error, chanLen)

	seelog.Infof("ssm secret resource: retrieving secrets for containers in task: [%s]", secret.taskARN)
	secret.secretData = make(map[string]string)

	for region, secrets := range secret.getRequiredSecrets() {
		wg.Add(1)
		// Spin up goroutine each region to speed up processing time
		go secret.retrieveSSMSecretValuesByRegion(region, secrets, iamCredentials, &wg, errorEvents)
	}

	wg.Wait()

	// Get the first error returned and set as terminal reason
	select {
	case err := <-errorEvents:
		secret.setTerminalReason(err.Error())
		return err
	default:
		return nil
	}
}
func ( secret * SSMSecretResource ) Create ( ) error { // To fail fast, check execution role first executionCredentials , ok := secret . credentialsManager . GetTaskCredentials ( secret . getExecutionCredentialsID ( ) ) if ! ok { // No need to log here. managedTask.applyResourceState already does that err := errors . New ( " " ) secret . setTerminalReason ( err . Error ( ) ) return err } iamCredentials := executionCredentials . GetIAMRoleCredentials ( ) var wg sync . WaitGroup // Get the maximum number of errors can be returned, which will be one error per goroutine chanLen := secret . getGoRoutineMaxNum ( ) errorEvents := make ( chan error , chanLen ) seelog . Infof ( " " , secret . taskARN ) secret . secretData = make ( map [ string ] string ) for region , secrets := range secret . getRequiredSecrets ( ) { wg . Add ( 1 ) // Spin up goroutine each region to speed up processing time go secret . retrieveSSMSecretValuesByRegion ( region , secrets , iamCredentials , & wg , errorEvents ) } wg . Wait ( ) // Get the first error returned and set as terminal reason select { case err := <- errorEvents : secret . setTerminalReason ( err . Error ( ) ) return err default : return nil } }
// Create fetches secret value from SSM in batches. It spins up multiple goroutines in order to
// retrieve values in parallel.
Create fetches secret value from SSM in batches . It spins up multiple goroutines in order to retrieve values in parallel .