github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/provider/ec2/cloud.go (about)

     1  // Copyright 2021 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package ec2
     5  
     6  import (
     7  	"github.com/juju/juju/cloud"
     8  	"github.com/juju/juju/environs"
     9  )
    10  
    11  type environProviderCloud struct{}
    12  
    13  // FinalizeCloud implements environs.CloudFinalizer.FinalizeCloud
    14  func (environProviderCloud) FinalizeCloud(
    15  	ctx environs.FinalizeCloudContext,
    16  	cld cloud.Cloud,
    17  ) (cloud.Cloud, error) {
    18  	// We want to make sure that the cloud at least has the instance role
    19  	// auth type in it's supported list as there may be alterations to a
    20  	// credential that forces this new type. Specifically this could happen
    21  	// during bootstrap. By adding it to the always supported list we are
    22  	// avoiding things blowing up. Added by tlm on 07/10/2021
    23  	if !cld.AuthTypes.Contains(cloud.InstanceRoleAuthType) {
    24  		cld.AuthTypes = append(cld.AuthTypes, cloud.InstanceRoleAuthType)
    25  	}
    26  
    27  	return cld, nil
    28  }