0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Tips】AWS SDKのエンドポイントを別のHTTPS Serverに変更する

Posted at

はじめに

AWSでの試験を楽にするためにLocalStackを使用したかったが、やむを得ない事情でローカルPCで起動することができなかったのでAWS上で起動することになり、その際通信をセキュアにするためにSSL化したら面倒くさかったのでメモ。

AWS SDK(Java)編

JavaのSDKでは、以下のように変更をする

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
import com.amazonaws.client.builder.AwsClientBuilder;

// (中略)
  final AmazonDynamoDB ddb = AmazonDynamoDBClientBuilder.standard()
                               .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(
                                 System.getenv("ENDPOINT"),
                                 "us-east-1"))
                               .build();
// (以下略)

証明書の情報は、予めkeytoolでJavaに登録しておこう。

AWS SDK(Golang)編

Go SDKでは、以下のように変更をする

import (
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/credentials"
	"github.com/aws/aws-sdk-go/aws/session"
)

// (中略)
	sess, _ := session.NewSession(&aws.Config{
		Region:           aws.String("us-east-1"),
		Credentials:      credentials.NewStaticCredentials("dummy", "dummy", ""),
		S3ForcePathStyle: aws.Bool(true),
		Endpoint:         aws.String(os.Getenv("ENDPOINT")),
	})
// (以下略)

なお、Golangの場合は、証明書の情報は、起動時に環境変数AWS_CA_BUNDLEに渡せば良い。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?