Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

IAM cross account #71

Closed
wants to merge 3 commits into from
Closed

IAM cross account #71

wants to merge 3 commits into from

Conversation

mattmb
Copy link
Contributor

@mattmb mattmb commented Apr 10, 2015

In order for a central platform to build/deploy to stacks created with this tool we need some AWS API access so that we can:

  • Find the master's IP address based on the tag created
  • Upload static assets to the S3 bucket (if created)

This PR adds some optional IAM roles that can be assumed from another account. This makes it possible for a deployment script to get the access described above from a limited user in a central AWS account.

@coveralls
Copy link

Coverage Status

Coverage increased (+1.15%) to 54.4% when pulling 85eea3e on iam-cross-account into 78707b7 on master.

@@ -57,6 +57,7 @@ def process(self):
elb = {}
output_templates = []

output_templates.append('stacks/iam_out.json')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed this needs an if block...

mattmb added 3 commits April 10, 2015 17:37
This adds the ability to give limited IAM access to other AWS accounts.
We need this so that our build/deploy server can get limited access to
the stacks we create even if they are in different accounts. The end
result is a IAM role ARN ID which can be assumed by a user in a
different account.
This adds an extra bit of code to the AWS api connection utility so
that it is possible to assume an IAM role from another account (if your
user has the right to). The ARN id of the role to assume is expected as
an environment variable.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.82%) to 54.08% when pulling fe99dfe on iam-cross-account into 78707b7 on master.

{
"Effect" : "Allow",
"Principal" : {
"AWS": "arn:aws:iam::ACCOUNT_NUMBER_HERE:root"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks suspect

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, this is munged by the config loader.

Rather than doing this and then changing the template inline how about we refer to a CFN Parameter. In the base.json:

"Parameters" : {
  "DeployAccountID" : {
    "Type" : "Number",
    "Description" : "Put a useful desc here"
  }
}

Then in the stack this bit becomes:

                         "Principal" : {
                             "AWS": { "Fn::Join" : ["",
                                 "arn:aws:iam::",
                                 { "Ref": "DeployAccountID" }
                                 ":root"
                             ] }
                         },

I think this makes it clearer - (it means that our python code has to do less at least)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is open for discussion if anyone disagrees

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that would make the code cleaner. To be clear you'd update the paramaters section from the code and just Ref it in the IAM section?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you just specify the parameters in the API call to CreateStack. Checking

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup http://boto.readthedocs.org/en/latest/ref/cloudformation.html#boto.cloudformation.connection.CloudFormationConnection.create_stack

Parameters:

  • parameters (list) – A list of key/value tuples that specify input parameters for the stack.

@stuartornum
Copy link
Contributor

Spoke with @mattmb about this - think we may try to solve another way, leaving bootstrap-cfn purely for AWS provisioning

@ashb
Copy link
Contributor

ashb commented Apr 13, 2015

Setting up the env to be able to deploy to it is part of provisioning to me, but if you can come up with a way that you are feel is better then sounds good 🐎

@stuartornum
Copy link
Contributor

@ashb - bootstrap-cfn is about provisioning of AWS services, template-deploy is about deploy.

@mattmb
Copy link
Contributor Author

mattmb commented Apr 13, 2015

We were thinking it might be nicer to setup includes. So that we can specify a json file that gets merged with the CF json. That way stuff like this could just be flat file in the template-deploy repo.

Only thing I need to check is that Ref'ing the S3 bucket name is possible.

@mattmb
Copy link
Contributor Author

mattmb commented Apr 13, 2015

Closing this and tackling the issue with #74 instead.

@mattmb mattmb closed this Apr 13, 2015
@ashb ashb removed the in progress label Apr 13, 2015
@ashb ashb deleted the iam-cross-account branch May 21, 2015 16:31
mattmb pushed a commit to ministryofjustice/moj-docker-deploy-formula that referenced this pull request Aug 27, 2015
This fixes a problem sudoing with fabric so that the limited deploy
user is able to run the deploy task over ssh. It also adds the central
AWS account as a trusted to access the IAM role neccessary to discover
the master and upload to S3. As per
ministryofjustice/bootstrap-cfn#71
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants