-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for instance profile credentials.
This PR adds support to the controller for using AWS instance profiles attached to it's machine. With this change we have introduced a new credential type and blocking to make sure the instance profile is attached to the controllers machine.
- Loading branch information
Showing
14 changed files
with
373 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2021 Canonical Ltd. | ||
// Licensed under the AGPLv3, see LICENCE file for details. | ||
|
||
package ec2 | ||
|
||
import ( | ||
"github.com/juju/juju/cloud" | ||
"github.com/juju/juju/environs" | ||
) | ||
|
||
type environProviderCloud struct{} | ||
|
||
// FinalizeCloud implements environs.CloudFinalizer.FinalizeCloud | ||
func (environProviderCloud) FinalizeCloud( | ||
ctx environs.FinalizeCloudContext, | ||
cld cloud.Cloud, | ||
) (cloud.Cloud, error) { | ||
// We want to make sure that the cloud at least has the instance role | ||
// auth type in it's supported list as there may be alterations to a | ||
// credential that forces this new type. Specifically this could happen | ||
// during bootstrap. By adding it to the always supported list we are | ||
// avoiding things blowing up. Added by tlm on 07/10/2021 | ||
if !cld.AuthTypes.Contains(cloud.InstanceRoleAuthType) { | ||
cld.AuthTypes = append(cld.AuthTypes, cloud.InstanceRoleAuthType) | ||
} | ||
|
||
return cld, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2021 Canonical Ltd. | ||
// Licensed under the AGPLv3, see LICENCE file for details. | ||
|
||
package ec2 | ||
|
||
import ( | ||
"sort" | ||
|
||
gc "gopkg.in/check.v1" | ||
|
||
"github.com/juju/juju/cloud" | ||
jc "github.com/juju/testing/checkers" | ||
) | ||
|
||
type cloudSuite struct { | ||
} | ||
|
||
var _ = gc.Suite(&cloudSuite{}) | ||
|
||
func (*cloudSuite) TestFinalizeCloudSetAuthTypes(c *gc.C) { | ||
environCloud := environProviderCloud{} | ||
r, err := environCloud.FinalizeCloud(nil, cloud.Cloud{}) | ||
c.Assert(err, jc.ErrorIsNil) | ||
sort.Sort(r.AuthTypes) | ||
c.Assert(r.AuthTypes, jc.DeepEquals, cloud.AuthTypes{"instance-role"}) | ||
} | ||
|
||
func (*cloudSuite) TestFinalizeCloudSetAuthTypesAddition(c *gc.C) { | ||
environCloud := environProviderCloud{} | ||
r, err := environCloud.FinalizeCloud(nil, cloud.Cloud{AuthTypes: cloud.AuthTypes{"test"}}) | ||
c.Assert(err, jc.ErrorIsNil) | ||
sort.Sort(r.AuthTypes) | ||
c.Assert(r.AuthTypes, jc.DeepEquals, cloud.AuthTypes{"instance-role", "test"}) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.