コード例 #1
0
def quick_start():
    click.echo("Quick Start running...")
    puppet_version = cli_command_helpers.get_puppet_version()
    with betterboto_client.ClientContextManager('sts') as sts:
        puppet_account_id = sts.get_caller_identity().get('Account')
        click.echo(
            "Going to use puppet_account_id: {}".format(puppet_account_id))
    click.echo("Bootstrapping account as a spoke")
    with betterboto_client.ClientContextManager(
            'cloudformation') as cloudformation:
        cli_command_helpers._do_bootstrap_spoke(puppet_account_id,
                                                cloudformation, puppet_version)

    click.echo("Setting the config")
    content = yaml.safe_dump(
        {"regions": ['eu-west-1', 'eu-west-2', 'eu-west-3']})
    with betterboto_client.ClientContextManager('ssm') as ssm:
        ssm.put_parameter(
            Name=constants.CONFIG_PARAM_NAME,
            Type='String',
            Value=content,
            Overwrite=True,
        )
        click.echo("Bootstrapping account as the master")
        org_iam_role_arn = cli_command_helpers._do_bootstrap_org_master(
            puppet_account_id, cloudformation, puppet_version)
        ssm.put_parameter(
            Name=constants.CONFIG_PARAM_NAME_ORG_IAM_ROLE_ARN,
            Type='String',
            Value=org_iam_role_arn,
            Overwrite=True,
        )
    click.echo("Bootstrapping the account now!")
    cli_command_helpers._do_bootstrap(puppet_version)

    if os.path.exists('ServiceCatalogPuppet'):
        click.echo("Found ServiceCatalogPuppet so not cloning or seeding")
    else:
        click.echo("Cloning for you")
        command = "git clone " \
                  "--config 'credential.helper=!aws codecommit credential-helper $@' " \
                  "--config 'credential.UseHttpPath=true' " \
                  "https://git-codecommit.{}.amazonaws.com/v1/repos/ServiceCatalogPuppet".format(
            os.environ.get("AWS_DEFAULT_REGION")
        )
        os.system(command)
        click.echo("Seeding")
        manifest = Template(
            asset_helpers.read_from_site_packages(
                os.path.sep.join(["manifests", "manifest-quickstart.yaml"
                                  ]))).render(ACCOUNT_ID=puppet_account_id)
        open(os.path.sep.join(["ServiceCatalogPuppet", "manifest.yaml"]),
             'w').write(manifest)
        click.echo("Pushing manifest")
        os.system(
            "cd ServiceCatalogPuppet && git add manifest.yaml && git commit -am 'initial add' && git push"
        )

    click.echo("All done!")
コード例 #2
0
def bootstrap_org_master(puppet_account_id):
    with betterboto_client.ClientContextManager(
            'cloudformation', ) as cloudformation:
        org_iam_role_arn = cli_command_helpers._do_bootstrap_org_master(
            puppet_account_id, cloudformation,
            cli_command_helpers.get_puppet_version())
    click.echo("Bootstrapped org master, org-iam-role-arn: {}".format(
        org_iam_role_arn))
コード例 #3
0
def bootstrap_spoke_as(puppet_account_id, iam_role_arns):
    cross_accounts = []
    index = 0
    for role in iam_role_arns:
        cross_accounts.append((role, 'bootstrapping-role-{}'.format(index)))
        index += 1

    with betterboto_client.CrossMultipleAccountsClientContextManager(
            'cloudformation', cross_accounts) as cloudformation:
        cli_command_helpers._do_bootstrap_spoke(
            puppet_account_id, cloudformation,
            cli_command_helpers.get_puppet_version())
コード例 #4
0
def bootstrap(with_manual_approvals):
    cli_command_helpers._do_bootstrap(
        cli_command_helpers.get_puppet_version(),
        with_manual_approvals,
    )
コード例 #5
0
def bootstrap_spoke(puppet_account_id):
    with betterboto_client.ClientContextManager(
            'cloudformation') as cloudformation:
        cli_command_helpers._do_bootstrap_spoke(
            puppet_account_id, cloudformation,
            cli_command_helpers.get_puppet_version())
コード例 #6
0
def bootstrap():
    cli_command_helpers._do_bootstrap(cli_command_helpers.get_puppet_version())