From ba9444d77ffee420901fa71cf77966908a6a5a8c Mon Sep 17 00:00:00 2001 From: Stuart Munro Date: Mon, 13 Apr 2015 14:23:49 +0100 Subject: [PATCH] Make the VPC configurable from with the YAML file If no VPC is specified in the YAML config, it will default to 10.0.0.0/16. Also updated the sample-project.yaml to include this change, and instead of copy/pasting the sample yaml to the README, we now link to it directly. --- README.rst | 91 +--------------------------------------- bootstrap_cfn/config.py | 2 + docs/sample-project.yaml | 22 ++++++---- 3 files changed, 17 insertions(+), 98 deletions(-) diff --git a/README.rst b/README.rst index 6941459..91cc19e 100644 --- a/README.rst +++ b/README.rst @@ -76,96 +76,7 @@ This tool needs AWS credentials to create stacks and the credentials should be p Project specific YAML file +++++++++++++++++++++++++++ -The YAML file below highlights what is possible with all the bootstrap-cfn features available to date. The minimum requirement is that it must contain an *ec2* block, you **do not** have to use RDS, S3 or ELB's. - -:: - - dev: - ec2: - auto_scaling: - desired: 1 - max: 3 - min: 0 - tags: - Role: docker - Apps: test - Env: dev - parameters: - KeyName: default - InstanceType: t2.micro - block_devices: - - DeviceName: /dev/sda1 - VolumeSize: 10 - - DeviceName: /dev/sdf - VolumeSize: 10 - security_groups: - MySecGroup: - - IpProtocol: tcp - FromPort: 22 - ToPort: 22 - CidrIp: 0.0.0.0/0 - - IpProtocol: tcp - FromPort: 80 - ToPort: 80 - CidrIp: 0.0.0.0/0 - elb: - - name: test-dev-external - hosted_zone: my.domain.com. - scheme: internet-facing - listeners: - - LoadBalancerPort: 80 - InstancePort: 80 - Protocol: TCP - - LoadBalancerPort: 443 - InstancePort: 443 - Protocol: TCP - - name: test-dev-internal - hosted_zone: my.domain.com. - scheme: internet-facing - security_groups: - ELBSecGroup: - - IpProtocol: tcp - FromPort: 80 - ToPort: 80 - CidrIp: 10.0.0.0/0 - listeners: - - LoadBalancerPort: 80 - InstancePort: 80 - Protocol: TCP - s3: - static-bucket-name: moj-test-dev-static - rds: - storage: 5 - storage-type: gp2 - backup-retention-period: 1 - identifier: test-dev - db-name: test - db-master-username: testuser - db-master-password: testpassword - instance-class: db.t2.micro - multi-az: false - db-engine: postgres - db-engine-version: 9.3.5 - ssl: - my-cert: - cert: | - -----BEGIN CERTIFICATE----- - blahblahblah - -----END CERTIFICATE----- - key: | - -----BEGIN RSA PRIVATE KEY----- - blahblahblah - -----END RSA PRIVATE KEY----- - chain: | - -----BEGIN CERTIFICATE----- - blahblahblah - -----END CERTIFICATE----- - salt: - local_salt_dir: ./salt - local_pillar_dir: ./pillar - local_vendor_dir: ./vendor - remote_state_dir: /srv/salt - remote_pillar_dir: /srv/pillar +The `YAML file `_ highlights what is possible with all the bootstrap-cfn features available to date. The minimum requirement is that it must contain an *ec2* block, you **do not** have to use RDS, S3 or ELB's. Salt specific configuration diff --git a/bootstrap_cfn/config.py b/bootstrap_cfn/config.py index 18e9562..527c644 100644 --- a/bootstrap_cfn/config.py +++ b/bootstrap_cfn/config.py @@ -86,6 +86,8 @@ def process(self): data[k] = v template = json.loads(pkgutil.get_data('bootstrap_cfn', 'stacks/base.json')) + if 'vpc' in self.data: + template['Mappings']['SubnetConfig']['VPC'] = self.data['vpc'] template['Resources'] = data template['Outputs'] = {} for t in output_templates: diff --git a/docs/sample-project.yaml b/docs/sample-project.yaml index 6605fe0..f35f2c9 100644 --- a/docs/sample-project.yaml +++ b/docs/sample-project.yaml @@ -1,4 +1,9 @@ dev: + vpc: + CIDR: 10.0.0.0/16 + SubnetA: 10.0.0.0/20 + SubnetB: 10.0.16.0/20 + SubnetC: 10.0.32.0/20 ec2: auto_scaling: desired: 1 @@ -17,14 +22,15 @@ dev: - DeviceName: /dev/sdf VolumeSize: 10 security_groups: - - IpProtocol: tcp - FromPort: 22 - ToPort: 22 - CidrIp: 0.0.0.0/0 - - IpProtocol: tcp - FromPort: 80 - ToPort: 80 - CidrIp: 0.0.0.0/0 + BaseSG: + - IpProtocol: tcp + FromPort: 22 + ToPort: 22 + CidrIp: 0.0.0.0/0 + - IpProtocol: tcp + FromPort: 80 + ToPort: 80 + CidrIp: 0.0.0.0/0 elb: - name: test-dev-external hosted_zone: kyrtest.pf.dsd.io.