-
Notifications
You must be signed in to change notification settings - Fork 55
feat: consume smithy-kotlin SigV4a implementation #1536
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0f5aa91
Remove UnsupportedSigningAlgorithmIntegration
lauzadis 6fa8b30
Merge branch 'main' of github.com:awslabs/aws-sdk-kotlin into feat-si…
lauzadis c3ceab2
ktlint
lauzadis ca26fc2
Remove unused runtime type
lauzadis 4c7ad7c
Deprecate UnsupportedSigningAlgorithmInterceptor instead of removing it
lauzadis 8c073b9
Changelog
lauzadis de470e5
Add DefaultAwsSigner to MRAP test
lauzadis b2fa1e3
ktlint
lauzadis a135924
Fix file name
lauzadis e421f19
Re-enable SESv2 SigV4a test
lauzadis 4c7c35d
ktlint
lauzadis e7e3fde
Upgrade to latest smithy-kotlin version
lauzadis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "id": "9636f12b-5612-41ec-a9ae-9434724e97a5", | ||
| "type": "feature", | ||
| "description": "Add SigV4a support to the default AWS signer" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 0 additions & 46 deletions
46
.../kotlin/aws/sdk/kotlin/codegen/customization/s3/UnsupportedSigningAlgorithmIntegration.kt
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,195 @@ | ||
| /* | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| package aws.sdk.kotlin.e2etest | ||
|
|
||
| import aws.sdk.kotlin.e2etest.S3TestUtils.deleteBucketAndAllContents | ||
| import aws.sdk.kotlin.e2etest.S3TestUtils.getAccountId | ||
| import aws.sdk.kotlin.e2etest.S3TestUtils.getBucketWithPrefix | ||
| import aws.sdk.kotlin.services.s3.S3Client | ||
| import aws.sdk.kotlin.services.s3.deleteObject | ||
| import aws.sdk.kotlin.services.s3.putObject | ||
| import aws.sdk.kotlin.services.s3.withConfig | ||
| import aws.sdk.kotlin.services.s3control.S3ControlClient | ||
| import aws.sdk.kotlin.services.s3control.createMultiRegionAccessPoint | ||
| import aws.sdk.kotlin.services.s3control.deleteMultiRegionAccessPoint | ||
| import aws.sdk.kotlin.services.s3control.describeMultiRegionAccessPointOperation | ||
| import aws.sdk.kotlin.services.s3control.getMultiRegionAccessPoint | ||
| import aws.sdk.kotlin.services.s3control.model.Region | ||
| import aws.smithy.kotlin.runtime.auth.awssigning.AwsSigner | ||
| import aws.smithy.kotlin.runtime.auth.awssigning.DefaultAwsSigner | ||
| import aws.smithy.kotlin.runtime.auth.awssigning.crt.CrtAwsSigner | ||
| import aws.smithy.kotlin.runtime.http.auth.SigV4AsymmetricAuthScheme | ||
| import kotlinx.coroutines.delay | ||
| import kotlinx.coroutines.runBlocking | ||
| import kotlinx.coroutines.withTimeout | ||
| import org.junit.jupiter.api.AfterAll | ||
| import org.junit.jupiter.api.BeforeAll | ||
| import org.junit.jupiter.api.TestInstance | ||
| import org.junit.jupiter.params.ParameterizedTest | ||
| import org.junit.jupiter.params.provider.Arguments | ||
| import org.junit.jupiter.params.provider.MethodSource | ||
| import java.util.stream.Stream | ||
| import kotlin.time.Duration | ||
| import kotlin.time.Duration.Companion.minutes | ||
| import kotlin.time.Duration.Companion.seconds | ||
|
|
||
| private const val MRAP_BUCKET_PREFIX = "s3-mrap-test-bucket-" | ||
| private const val MULTI_REGION_ACCESS_POINT_NAME = "aws-sdk-for-kotlin-test-multi-region-access-point" | ||
| private const val TEST_OBJECT_KEY = "test.txt" | ||
|
|
||
| @TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
| class MutliRegionAccessPointTest { | ||
| private lateinit var s3West: S3Client | ||
| private lateinit var s3East: S3Client | ||
| private lateinit var s3Control: S3ControlClient | ||
|
|
||
| private lateinit var accountId: String | ||
| private lateinit var multiRegionAccessPointArn: String | ||
| private lateinit var usWestBucket: String | ||
| private lateinit var usEastBucket: String | ||
|
|
||
| @BeforeAll | ||
| fun setup(): Unit = runBlocking { | ||
| s3West = S3Client { region = "us-west-2" } | ||
| s3East = S3Client { region = "us-east-2" } | ||
| s3Control = S3ControlClient { region = "us-west-2" } | ||
|
|
||
| accountId = getAccountId() | ||
| usWestBucket = getBucketWithPrefix(s3West, MRAP_BUCKET_PREFIX, "us-west-2", accountId) | ||
| usEastBucket = getBucketWithPrefix(s3East, MRAP_BUCKET_PREFIX, "us-east-2", accountId) | ||
|
|
||
| multiRegionAccessPointArn = s3Control.createMultiRegionAccessPoint( | ||
| MULTI_REGION_ACCESS_POINT_NAME, | ||
| accountId, | ||
| listOf(usWestBucket, usEastBucket), | ||
| ) | ||
| } | ||
|
|
||
| @AfterAll | ||
| fun cleanup(): Unit = runBlocking { | ||
| s3Control.deleteMultiRegionAccessPoint(MULTI_REGION_ACCESS_POINT_NAME, accountId) | ||
|
|
||
| deleteBucketAndAllContents(s3West, usWestBucket) | ||
| deleteBucketAndAllContents(s3East, usEastBucket) | ||
|
|
||
| s3West.close() | ||
| s3East.close() | ||
| s3Control.close() | ||
| } | ||
|
|
||
| @ParameterizedTest | ||
| @MethodSource("signerProvider") | ||
| fun testMultiRegionAccessPointOperation(signer: AwsSigner): Unit = runBlocking { | ||
| println("Testing multi-region access point operations with $signer") | ||
|
|
||
| val s3SigV4a = s3West.withConfig { | ||
| authSchemes = listOf(SigV4AsymmetricAuthScheme(signer)) | ||
| } | ||
|
|
||
| s3SigV4a.putObject { | ||
| bucket = multiRegionAccessPointArn | ||
| key = TEST_OBJECT_KEY | ||
| } | ||
|
|
||
| s3SigV4a.deleteObject { | ||
| bucket = multiRegionAccessPointArn | ||
| key = TEST_OBJECT_KEY | ||
| } | ||
| } | ||
|
|
||
| fun signerProvider(): Stream<Arguments> = Stream.of( | ||
| Arguments.of(DefaultAwsSigner), | ||
| Arguments.of(CrtAwsSigner), | ||
| ) | ||
| } | ||
|
|
||
| /** | ||
| * Create a multi-region access point named [name] in account [accountId] with [buckets] buckets. | ||
| * @return the ARN of the multi-region access point that was created | ||
| */ | ||
| private suspend fun S3ControlClient.createMultiRegionAccessPoint( | ||
| name: String, | ||
| accountId: String, | ||
| buckets: List<String>, | ||
| ): String { | ||
| println("Creating multi-region access point: $name") | ||
|
|
||
| val requestTokenArn = checkNotNull( | ||
| createMultiRegionAccessPoint { | ||
| this.accountId = accountId | ||
| details { | ||
| this.name = name | ||
| this.regions = buckets.map { Region { bucket = it } } | ||
| } | ||
| }.requestTokenArn, | ||
| ) { "createMultiRegionAccessPoint requestTokenArn was unexpectedly null" } | ||
|
|
||
| waitUntilOperationCompletes("createMultiRegionAccessPoint", accountId, requestTokenArn, 10.minutes) | ||
|
|
||
| return getMultiRegionAccessPointArn(name, accountId) | ||
| } | ||
|
|
||
| private suspend fun S3ControlClient.getMultiRegionAccessPointArn( | ||
| name: String, | ||
| accountId: String, | ||
| ): String = getMultiRegionAccessPoint { | ||
| this.name = name | ||
| this.accountId = accountId | ||
| }.accessPoint?.alias?.let { | ||
| "arn:aws:s3::$accountId:accesspoint/$it" | ||
| } ?: throw IllegalStateException("Failed to get ARN for multi-region access point $name") | ||
|
|
||
| private suspend fun S3ControlClient.deleteMultiRegionAccessPoint( | ||
| name: String, | ||
| accountId: String, | ||
| ) { | ||
| println("Deleting multi-region access point $name") | ||
|
|
||
| val requestTokenArn = checkNotNull( | ||
| deleteMultiRegionAccessPoint { | ||
| this.accountId = accountId | ||
| details { | ||
| this.name = name | ||
| } | ||
| }.requestTokenArn, | ||
| ) { "deleteMultiRegionAccessPoint requestTokenArn was unexpectedly null" } | ||
|
|
||
| waitUntilOperationCompletes("deleteMultiRegionAccessPoint", accountId, requestTokenArn, 5.minutes) | ||
| } | ||
|
|
||
| /** | ||
| * Continuously poll the status of [requestTokenArn] until its status is "SUCCEEDED" or [timeout] duration has passed. | ||
| */ | ||
| private suspend fun S3ControlClient.waitUntilOperationCompletes( | ||
| operation: String, | ||
| accountId: String, | ||
| requestTokenArn: String, | ||
| timeout: Duration, | ||
| ) = withTimeout(timeout) { | ||
| var status: String? = null | ||
|
|
||
| while (true) { | ||
| val latestStatus = describeMultiRegionAccessPointOperation { | ||
| this.accountId = accountId | ||
| this.requestTokenArn = requestTokenArn | ||
| }.asyncOperation?.requestStatus | ||
|
|
||
| when (latestStatus) { | ||
| "SUCCEEDED" -> { | ||
| println("$operation operation succeeded.") | ||
| return@withTimeout | ||
| } | ||
| "FAILED" -> throw IllegalStateException("$operation operation failed") | ||
| else -> { | ||
| if (status == null || latestStatus != status) { | ||
| println("Waiting for $operation to complete. Status: $latestStatus ") | ||
| status = latestStatus | ||
| } | ||
| } | ||
| } | ||
|
|
||
| delay(10.seconds) // Avoid constant status checks | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: I renamed the file (fixing a typo) which causes this massive diff. See this commit for a more accurate view of the changes: de470e5