Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13394 from tlm/aws-instance-profile
#13394 This PR adds support to the controller for using AWS instance profiles attached to its machine. With this change we have introduced a new credential type and blocking to make sure the instance profile is attached to the controller's machine. ## Checklist - [x] Requires a [pylibjuju](https://github.com/juju/python-libjuju) change - [x] Added [integration tests](https://github.com/juju/juju/tree/develop/tests) for the PR - [x] Added or updated [doc.go](https://discourse.jujucharms.com/t/readme-in-packages/451) related to packages changed - [x] Comments answer the question of why design decisions were made ## QA steps 1. Create a new instance profile ``` aws iam create-instance-profile --instance-profile-name tlm-ip-test { "InstanceProfile": { "Roles": [], "InstanceProfileName": "tlm-ip-test", "Path": "/", } } ``` 2. Add a role to the instance profile. THIS MUST BE DONE or the boostrap will hang in waiting for association. ``` aws iam add-role-to-instance-profile --instance-profile-name tlm-ip-test --role-name <role_name> ``` 3. Do the bootstrap with: ``` juju bootstrap --bootstrap-constraints="instance-role=tlm-ip-test" aws/ap-southeast-2 test-ip-controller ``` NOTE: the auto keywork to instance-role will work in create an instance profile for the controller but the bootstrap will hang as we currently don't have the role sorted for the controller yet so we must create it our selves until the next PR.
- 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.