Skip to content

Commit

Permalink
Bulk Load CDK: micronaut nonsense (#52627)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgao authored Jan 29, 2025
1 parent abb103d commit ae01f28
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package io.airbyte.cdk.load.command.aws

import io.micronaut.context.annotation.Requires
import io.micronaut.context.annotation.Value
import io.micronaut.context.condition.Condition
import io.micronaut.context.condition.ConditionContext
import javax.inject.Singleton

// For some reason, micronaut doesn't handle plain `@Requires(property = "...")` when you declare
Expand All @@ -14,9 +16,18 @@ import javax.inject.Singleton
// but then tries to inject a null value to the field, which obviously throws an exception.
// So instead, we declare the property as `${FOO_BAR:}` (i.e. default to empty string)
// and set a property notEquals empty string requirement.
@Requires(property = ACCESS_KEY_PROPERTY, notEquals = "")
@Requires(property = SECRET_KEY_PROPERTY, notEquals = "")
@Requires(property = EXTERNAL_ID_PROPERTY, notEquals = "")

// You might expect that after dealing with that mess, we could just declare three @Requires flags,
// like so:
// @Requires(property = ACCESS_KEY_PROPERTY, notEquals = "")
// @Requires(property = SECRET_KEY_PROPERTY, notEquals = "")
// @Requires(property = EXTERNAL_ID_PROPERTY, notEquals = "")

// However, micronaut sometimes decides to not load the bean, when there are three different
// @Requires annotations.
// So instead we define a custom condition, which does the _exact same thing_,
// but lets us use only a single Requires annotation.
@Requires(condition = AssumeRoleCredentialsCondition::class)
@Singleton
data class AwsAssumeRoleCredentials(
@Value("\${$ACCESS_KEY_PROPERTY}") val accessKey: String,
Expand All @@ -29,3 +40,13 @@ data class AwsAssumeRoleCredentials(
const val ACCESS_KEY_PROPERTY = "airbyte.destination.aws.assume-role.access-key"
const val SECRET_KEY_PROPERTY = "airbyte.destination.aws.assume-role.secret-key"
const val EXTERNAL_ID_PROPERTY = "airbyte.destination.aws.assume-role.external-id"

private object AssumeRoleCredentialsCondition : Condition {
override fun matches(context: ConditionContext<*>): Boolean {
val accessKey = context.getProperty(ACCESS_KEY_PROPERTY, String::class.java).orElse("")
val secretKey = context.getProperty(SECRET_KEY_PROPERTY, String::class.java).orElse("")
val externalId = context.getProperty(EXTERNAL_ID_PROPERTY, String::class.java).orElse("")

return accessKey.isNotEmpty() && secretKey.isNotEmpty() && externalId.isNotEmpty()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ data:
connectorSubtype: file
connectorType: destination
definitionId: 4816b78f-1489-44c1-9060-4b19d5fa9362
dockerImageTag: 1.5.0-rc.15
dockerImageTag: 1.5.0-rc.16
dockerRepository: airbyte/destination-s3
githubIssueLabel: destination-s3
icon: s3.svg
Expand Down
3 changes: 2 additions & 1 deletion docs/integrations/destinations/s3.md
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,8 @@ To see connector limitations, or troubleshoot your S3 connector, see more [in ou

| Version | Date | Pull Request | Subject |
|:------------|:-----------|:-----------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------|
| 1.5.0-rc.15 | 2025-01-23 | [52103](https://github.com/airbytehq/airbyte/pull/52103) | Make the connector use our non root base image. |
| 1.5.0-rc.16 | 2025-01-29 | [52610](https://github.com/airbytehq/airbyte/pull/52610) | Fix assume role behavior |
| 1.5.0-rc.15 | 2025-01-23 | [52103](https://github.com/airbytehq/airbyte/pull/52103) | Make the connector use our non root base image. |
| 1.5.0-rc.14 | 2025-01-24 | [51600](https://github.com/airbytehq/airbyte/pull/51600) | Internal refactor |
| 1.5.0-rc.13 | 2025-01-22 | [52076](https://github.com/airbytehq/airbyte/pull/52076) | Test improvements. |
| 1.5.0-rc.12 | 2025-01-22 | [52072](https://github.com/airbytehq/airbyte/pull/52072) | Bug fix: Configure OpenStreamTask concurrency to handle connection to reduce http connection errors. |
Expand Down

0 comments on commit ae01f28

Please sign in to comment.