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

Add endpoint to RDS DBCluster connection details #696

Merged
merged 1 commit into from Jun 3, 2021

Conversation

benagricola
Copy link
Contributor

@benagricola benagricola commented Jun 3, 2021

Description of your changes

Endpoint was not being copied into the connection details of the generated RDS DBCluster reconciler. This adds the endpoint field as it is trivially available in the status of the resource, and returns the FQDN (minus port) of the instance.

This does not set the port as well, as it is not exposed by the status. I suspect in most cases this is defaulted from the AWS side, and it doesn't look like late init is implemented for this reconciler yet (so we potentially have no value to populate).

Fixes #695

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

Test suite passes but I don't think this particular method is directly targeted. Will be using the built image to test on a live cluster.

Fixes crossplane-contrib#695

Signed-off-by: Ben Agricola <bagricola@squiz.co.uk>
Copy link
Member

@hasheddan hasheddan left a comment

Choose a reason for hiding this comment

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

LGTM pending your test results :) Thanks!

@benagricola
Copy link
Contributor Author

Tested using the following resource:

apiVersion: rds.aws.crossplane.io/v1alpha1
kind: DBCluster
metadata:
  name: example-dbcluster
spec:
  forProvider:
    region: us-east-1
    engineMode: serverless
    engine: aurora-mysql
    masterUsername: admin
    masterUserPasswordSecretRef:
      name: dbcluster-pwd
      namespace: crossplane-system
      key: password
    dbSubnetGroupName: example-dbsubnet-group
    vpcSecurityGroupIDs:
      - sg-<redacted>
    databaseName: exampledbcluster
  writeConnectionSecretToRef:
    name: mysqlserver-conn
    namespace: crossplane-system

Which after reconciliation, produced the following DBCluster:

apiVersion: rds.aws.crossplane.io/v1alpha1
kind: DBCluster
metadata:
annotations:
    crossplane.io/external-name: example-dbcluster
name: example-dbcluster
spec:
    deletionPolicy: Delete
    forProvider:
        databaseName: exampledbcluster
        dbSubnetGroupName: example-dbsubnet-group
        engine: aurora-mysql
        engineMode: serverless
        masterUserPasswordSecretRef:
        key: password
        name: dbcluster-pwd
        namespace: crossplane-system
        masterUsername: admin
        region: us-east-1
        vpcSecurityGroupIDs:
        - sg-<redacted>
    providerConfigRef:
        name: default
    writeConnectionSecretToRef:
        name: mysqlserver-conn
        namespace: crossplane-system
status:
    atProvider:
        activityStreamStatus: stopped
        allocatedStorage: 1
        capacity: 8
        clusterCreateTime: "2021-06-03T14:51:12Z"
        crossAccountClone: false
        dbClusterARN: arn:aws:rds:us-east-1:<redacted>:cluster:example-dbcluster
        dbClusterIdentifier: example-dbcluster
        dbClusterParameterGroup: default.aurora-mysql5.7
        dbClusterResourceID: cluster-<redacted>
        dbSubnetGroup: example-dbsubnet-group
        earliestRestorableTime: "2021-06-03T14:52:07Z"
        endpoint: example-dbcluster.cluster-<redacted>.us-east-1.rds.amazonaws.com
        hostedZoneID: <redacted>
        httpEndpointEnabled: false
        iamDatabaseAuthenticationEnabled: false
        latestRestorableTime: "2021-06-03T14:52:07Z"
        multiAZ: false
        scalingConfigurationInfo:
            autoPause: true
            maxCapacity: 16
            minCapacity: 2
            secondsUntilAutoPause: 300
            timeoutAction: RollbackCapacityChange
        status: available
        vpcSecurityGroups:
            - status: active
              vpcSecurityGroupID: sg-<redacted>

And the corresponding secret:

➜  crossplane-test-resources k get secret -n crossplane-system mysqlserver-conn -o jsonpath='{.data.endpoint}' | base64 -d
example-dbcluster.cluster-<redacted>.us-east-1.rds.amazonaws.com%

@muvaf muvaf merged commit 1034e22 into crossplane-contrib:master Jun 3, 2021
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.

DBCluster generated secret doesn't contain database endpoint
4 participants