3
1

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 3 years have passed since last update.

localstackでredshiftとs3を立ててみる

Last updated at Posted at 2021-09-08

どういう記事か

とりあえずlocalstackの環境構築を行なってredshiftとs3を使ってみた記事です。

参考

前提

m1 mac

docker-compose

docker-compose.yml
version: '3'
 
services:
  # LocalStack
  localstack:
    image: localstack/localstack:latest
    environment:
      - SERVICES=s3,redshift # 使いたいAWSサービスカンマ区切りで設定する
      - DEFAULT_REGION=ap-northeast-1 # リージョンを設定
      - DATA_DIR=/tmp/localstack/data # データ保存するディレクトリ
    volumes:
      - ./localstack:/tmp/localstack # ローカルディレクトリをデータ保存ディレクトリへマウント
    ports:
      - 4566:4566 # サービスへのアクセスポートは4566

プロフィールの変更

$ aws configure list
      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                <not set>             None    None
access_key     **************** shared-credentials-file
secret_key     **************** shared-credentials-file
    region           ap-northeast-1      config-file    ~/.aws/config

以下のようにプロフィールを設定します。

$ aws configure --profile localstack
AWS Access Key ID [None]: dummy
AWS Secret Access Key [None]: dummy
Default region name [None]: ap-northeast-1
Default output format [None]:

これで .awsの中のcredentialsも変わっているはずです。

$ cat credentials
[localstack]
aws_access_key_id = dummy
aws_secret_access_key = dummy

バケットを作ってみる

$ aws s3 mb s3://sample-bucket --endpoint-url=http://localhost:4566 --profile localstack
make_bucket: sample-bucket

$ aws s3 ls --endpoint-url=http://localhost:4566 --profile localstack
2021-09-07 14:50:18 sample-bucket

redshiftのクラスター作成

$ aws redshift create-cluster --cluster-identifier example --node-type dw.hs1.xlarge --master-username user --master-user-password cmpass --profile localstack --endpoint-url=http://localhost:4566

// レスポンス
{
    "Cluster": {
        "ClusterIdentifier": "example",
        "NodeType": "dw.hs1.xlarge",
        "ClusterStatus": "creating",
        "MasterUsername": "user",
        "DBName": "dev",
        "Endpoint": {
            "Address": "example.cg034hpkmmjt.ap-northeast-1.redshift.amazonaws.com",
            "Port": 5439
        },
        "ClusterCreateTime": "2021-09-07T05:58:36.131000+00:00",
        "AutomatedSnapshotRetentionPeriod": 1,
        "ClusterSecurityGroups": [
            {
                "ClusterSecurityGroupName": "Default",
                "Status": "active"
            }
        ],
        "VpcSecurityGroups": [],
        "ClusterParameterGroups": [
            {
                "ParameterGroupName": "default.redshift-1.0",
                "ParameterApplyStatus": "in-sync"
            }
        ],
        "ClusterSubnetGroupName": "",
        "AvailabilityZone": "ap-northeast-1a",
        "PreferredMaintenanceWindow": "Mon:03:00-Mon:03:30",
        "PendingModifiedValues": {},
        "ClusterVersion": "1.0",
        "AllowVersionUpgrade": true,
        "NumberOfNodes": 1,
        "PubliclyAccessible": false,
        "Encrypted": false,
        "Tags": [],
        "KmsKeyId": "",
        "EnhancedVpcRouting": false,
.......

redshiftのクラスターのリストを取得したいとき

aws redshift describe-clusters --profile localstack --endpoint-url=http://localhost:4566

これでredshiftのクラスター周りは処理が可能です!

3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?