Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial attempt at new RDS blueprint framework #86

Merged
merged 7 commits into from
Sep 7, 2015
Merged

Conversation

phobologic
Copy link
Member

Still a WIP - mostly opening for discussion about the new
framework.


ENGINE = None

def _get_engine_versions(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

if something should be overridden, i usually don't put an underscore since it implies some sort of public api

class ReadReplica(MasterInstance):
""" Blueprint for a Read replica RDS Database Instance. """
def _get_parameters(self):
parameters = common_parameters()
Copy link
Contributor

Choose a reason for hiding this comment

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

why not just do:

parameters = super(ReadReplica, self).get_parameters()

and have common_parameters returned

Copy link
Member Author

Choose a reason for hiding this comment

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

There are parameters that come from the MasterInstance that shouldn't be used in ReadReplicas. A better design might be to have a BaseInstance type or something, and have MasterInstance & ReadReplica both subclass off of it, rather than ReadReplica being based on MasterInstance.

Copy link
Contributor

Choose a reason for hiding this comment

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

i see yea, not a big deal, you're just calling common_parameters and overriding it in both places.

t.add_resource(
DBInstance(
DBINSTANCE_NO_IOPS,
Condition="NoProvisionedIOPS",
Copy link
Contributor

Choose a reason for hiding this comment

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

i would pull out all of these common parameters so i don't have to duplicate specifying them in each

Copy link
Member Author

Choose a reason for hiding this comment

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

Hard/ugly to do? How would you do it? Just args/*kwargs?

Copy link
Contributor

Choose a reason for hiding this comment

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

i was just thinking like:

common = {
    'AllocatedStorage': Ref("AllocatedStorage"),
    'AllowMajorVersionUpgrade': Ref("AllowMajorVersionUpgrade"),
    'AutoMinorVersionUpgrade': Ref("AutoMinorVersionUpgrade"),
    'BackupRetentionPeriod': Ref("BackupRetentionPeriod"),
    'DBName': Ref("DatabaseName"),
    'DBInstanceClass': Ref("InstanceType"),
    'DBSubnetGroupName': Ref(SUBNET_GROUP),
    'Engine': self.ENGINE or Ref("Engine"),
    'EngineVersion': Ref("EngineVersion"),
    'MasterUsername': Ref("MasterUser"),
    'MasterUserPassword': Ref("MasterUserPassword"),
    'MultiAZ': Ref("MultiAZ"),
    'PreferredBackupWindow': Ref("PreferredBackupWindow"),
    'VPCSecurityGroups': [Ref(SECURITY_GROUP), ],
    'StorageEncrypted': Ref("StorageEncrypted"),
}
t.add_resource(
    DBInstance(
        DBINSTANCE_NO_IOPS,
        Condition="NoProvisionedIOPS",
        **common
     )
)
t.add_resource(
    DBInstance(
        DBINSTANCE_WITH_IOPS,
        Condition="ProvisionedIOPS",
        StorageEncrypted=Ref("StorageEncrypted"),
        StorageType="io1",
        Iops=Ref("IOPS"),
        **common
    )
)

which also has the added benefit of letting me see whats different about the two.

not sure if thats 100% accurate just a rough copy paste

@mwildehahn
Copy link
Contributor

+1 i like it!

This tries to pull in every DBInstance Parameter in as a 'default'.  The
only ones not modified are:

AvailabilityZone: Can't be used w/ MultiAZ, can be added later or in
                  subclasses
CharacterSetName: Oracle only
DBInstanceIdentifier: Very dependent on the underlying Engine
DBSecurityGroups: Not used in VPC
DBSnapshotIdentifier: Used to create database from backup, could be done
                      later
Port: Default dependent on Engine, don't want to mess with it.
PubliclyAccessible: Kind of hard to use, not the primary use case really
Mappings evidently only allow alphanumeric values in keys, which breaks
things. This isn't as useful without it, and it's a bit more parameters
to setup, but at least it works.

Also cleans up the need for multiple DBInstances per stack by using
AWS:NoValue.
@mwildehahn
Copy link
Contributor

+1 again :)

- create base class for RDS
- use mixins for each of the engine specific classes
- Built in logic to figure out major version allowed from version
- allow subclasses to set their own allowed values for:
  - engine_major_version
  - db family
- Got rid of ENGINE class variable, use engine() method now
- added example confs & envs for mysql & postgres clusters
phobologic added a commit that referenced this pull request Sep 7, 2015
Initial attempt at new RDS blueprint framework
@phobologic phobologic merged commit 7a44c26 into master Sep 7, 2015
@phobologic phobologic deleted the rds_v2 branch September 7, 2015 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants