-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added bootstrap-org-master command to help with AWS Organizations integration
- Loading branch information
1 parent
f406e01
commit 0fee82e
Showing
6 changed files
with
125 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from jinja2 import Template | ||
|
||
import logging | ||
|
||
|
||
from servicecatalog_puppet.asset_helpers import read_from_site_packages | ||
from servicecatalog_puppet.constants import BOOTSTRAP_STACK_NAME | ||
from servicecatalog_puppet.constants import PUPPET_ORG_ROLE_FOR_EXPANDS_ARN | ||
|
||
logger = logging.getLogger(__file__) | ||
|
||
|
||
def do_bootstrap_org_master(puppet_account_id, cloudformation, puppet_version): | ||
logger.info('Starting bootstrap of org master') | ||
stack_name = "{}-org-master".format(BOOTSTRAP_STACK_NAME) | ||
template = read_from_site_packages('{}.template.yaml'.format(stack_name)) | ||
template = Template(template).render(VERSION=puppet_version) | ||
args = { | ||
'StackName': stack_name, | ||
'TemplateBody': template, | ||
'Capabilities': ['CAPABILITY_NAMED_IAM'], | ||
'Parameters': [ | ||
{ | ||
'ParameterKey': 'PuppetAccountId', | ||
'ParameterValue': str(puppet_account_id), | ||
}, { | ||
'ParameterKey': 'Version', | ||
'ParameterValue': puppet_version, | ||
'UsePreviousValue': False, | ||
}, | ||
], | ||
} | ||
cloudformation.create_or_update(**args) | ||
response = cloudformation.describe_stacks(StackName=stack_name) | ||
if len(response.get('Stacks')) != 1: | ||
raise Exception("Expected there to be only one {} stack".format(stack_name)) | ||
stack = response.get('Stacks')[0] | ||
|
||
for output in stack.get('Outputs'): | ||
if output.get('OutputKey') == PUPPET_ORG_ROLE_FOR_EXPANDS_ARN: | ||
logger.info('Finished bootstrap of org-master') | ||
return output.get("OutputValue") | ||
|
||
raise Exception("Could not find output: {} in stack: {}".format(PUPPET_ORG_ROLE_FOR_EXPANDS_ARN, stack_name)) | ||
|
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
54 changes: 54 additions & 0 deletions
54
servicecatalog_puppet/servicecatalog-puppet-org-master.template.yaml
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,54 @@ | ||
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
AWSTemplateFormatVersion: "2010-09-09" | ||
|
||
Parameters: | ||
PuppetAccountId: | ||
Type: String | ||
MinLength: 12 | ||
MaxLength: 12 | ||
Version: | ||
Type: String | ||
Default: "{{ VERSION }}" | ||
|
||
Resources: | ||
Param: | ||
Type: AWS::SSM::Parameter | ||
Properties: | ||
Name: service-catalog-puppet-org-master-version | ||
Type: String | ||
Value: !Ref Version | ||
|
||
PuppetOrgRoleForExpands: | ||
Type: AWS::IAM::Role | ||
Properties: | ||
RoleName: PuppetOrgRoleForExpands | ||
Path: /servicecatalog-puppet/ | ||
Policies: | ||
- PolicyName: "allowExpands" | ||
PolicyDocument: | ||
Version: "2012-10-17" | ||
Statement: | ||
- Effect: "Allow" | ||
Action: | ||
- organizations:ListRoots | ||
- organizations:DescribeAccount | ||
- organizations:ListOrganizationalUnitsForParent | ||
- organizations:ListChildren | ||
Resource: "*" | ||
|
||
AssumeRolePolicyDocument: | ||
Version: "2012-10-17" | ||
Statement: | ||
- Effect: "Allow" | ||
Principal: | ||
AWS: !Sub "arn:aws:iam::${PuppetAccountId}:root" | ||
Action: | ||
- "sts:AssumeRole" | ||
|
||
Outputs: | ||
PuppetOrgRoleForExpandsArn: | ||
Value: !GetAtt PuppetOrgRoleForExpands.Arn | ||
|
||
Version: | ||
Value: !GetAtt Param.Value |
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
|
||
setuptools.setup( | ||
name="aws-service-catalog-puppet", | ||
version="0.0.38", | ||
version="0.0.39", | ||
author="Eamonn Faherty", | ||
author_email="[email protected]", | ||
description="Making it easier to deploy ServiceCatalog products", | ||
|