尽管默认官方提供了s3 的操作,但是对于开源minio 无法支持,更多的是aws 的s3,社区提供了一个通用
s3 操作的provider(基于minio 的sdk)

环境准备

  • docker-compose 文件
version: "3"
services:
s3:
image: minio/minio
command: server /export
ports:
- "9000:9000"
volumes:
- ./data:/export
- ./config:/root/.minio
environment:
- "MINIO_ACCESS_KEY=dalongdemo"
- "MINIO_SECRET_KEY=dalongdemo"
  • s3 terraform 操作
    添加了依赖处理以及一个简单静态web 页面部署
provider "s3" {
s3_server = "localhost:9000"
s3_access_key = "dalongdemo"
s3_secret_key = "dalongdemo"
s3_api_signature = "v4"
s3_ssl = false
s3_debug = true
} resource "s3_bucket" "bucket_create" {
bucket = "s3page"
} resource "s3_file" "upload_index_page" {
bucket = "s3page"
name = "index.html"
file_path = "./files/index.html"
content_type = "text.html"
debug = true
depends_on = ["s3_bucket.bucket_create"]
} resource "s3_file" "upload_user_js" {
bucket = "s3page"
name = "user.js"
file_path = "./files/user.js"
content_type = "application/javascript"
debug = true
depends_on = ["s3_bucket.bucket_create"] }

部署

  • 插件准备
我测试环境是mac,使用go get 安装provider,然后copy plugin 到tf 定义文件目录,注意需要创建目录
mkdir -p ./.terraform/plugins/darwin_amd64/
./.terraform/plugins/darwin_amd64/
  • init
terraform init
  • 查看plan
terraform plan

效果

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create Terraform will perform the following actions: + s3_bucket.bucket_create
id: <computed>
bucket: "s3page"
debug: "false" + s3_file.upload_index_page
id: <computed>
bucket: "s3page"
content_type: "text.html"
debug: "true"
file_path: "./files/index.html"
name: "index.html" + s3_file.upload_user_js
id: <computed>
bucket: "s3page"
content_type: "application/javascript"
debug: "true"
file_path: "./files/user.js"
name: "user.js" Plan: 3 to add, 0 to change, 0 to destroy. ------------------------------------------------------------------------ Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.
  • apply
terraform apply

效果

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create Terraform will perform the following actions: + s3_bucket.bucket_create
id: <computed>
bucket: "s3page"
debug: "false" + s3_file.upload_index_page
id: <computed>
bucket: "s3page"
content_type: "text.html"
debug: "true"
file_path: "./files/index.html"
name: "index.html" + s3_file.upload_user_js
id: <computed>
bucket: "s3page"
content_type: "application/javascript"
debug: "true"
file_path: "./files/user.js"
name: "user.js" Plan: 3 to add, 0 to change, 0 to destroy. Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve. Enter a value: yes s3_bucket.bucket_create: Creating...
bucket: "" => "s3page"
debug: "" => "false"
s3_bucket.bucket_create: Creation complete after 0s
s3_file.upload_index_page: Creating...
bucket: "" => "s3page"
content_type: "" => "text.html"
debug: "" => "true"
file_path: "" => "./files/index.html"
name: "" => "index.html"
s3_file.upload_user_js: Creating...
bucket: "" => "s3page"
content_type: "" => "application/javascript"
debug: "" => "true"
file_path: "" => "./files/user.js"
name: "" => "user.js"
s3_file.upload_index_page: Creation complete after 0s
s3_file.upload_user_js: Creation complete after 0s Apply complete! Resources: 3 added, 0 changed, 0 destroyed.
  • minio 界面
  • 设置浏览器访问
  • 直接访问

说明

terraform-provider-s3 功能还算不错,使用起来也比较简单,但是功能还不是很多,比如设置策略,配置通知。。。。,文件夹数据复制,
桶数据复制,但是实现起来还是相对简单的,可以参考provider 开发

参考资料

https://github.com/negronjl/terraform-provider-s3
https://github.com/rongfengliang/terraform-minio-s3-provider-demo

 
 
 
 

使用terraform-provider-s3 操作minio的更多相关文章

  1. Write your own Terraform provider: Part 1

    转自:https://container-solutions.com/write-terraform-provider-part-1/ This is the first part of a seri ...

  2. 四、C#简单操作MinIO

    MinIO的官方网站非常详细,以下只是本人学习过程的整理 一.MinIO的基本概念 二.Windows安装与简单使用MinIO 三.Linux部署MinIO分布式集群 四.C#简单操作MinIO He ...

  3. 京东云携手HashiCorp,宣布推出Terraform Provider

    2019年4月23日消息,京东云携手云基础设施自动化软件的领导者HashiCorp,宣布推出Terraform Provider for JD Cloud,这意味着用户能够在京东云上轻松使用简单模板语 ...

  4. drill 集成开源s3 存储minio

    drill 支持s3数据的查询,同时新版的通过简单配置就可以实现minio 的集成 测试使用docker 运行drill 参考 https://www.cnblogs.com/rongfenglian ...

  5. Amazon AWS S3 操作手册

    Install the SDK The recommended way to use the AWS SDK for Java in your project is to consume it fro ...

  6. content provider其中操作文件的函数

    此类函数还是有杀伤力的 1.openAssetFile(Uri uri, String mode)This is like openFile(Uri, String), but can be impl ...

  7. 使用s3fs-fuse 挂载minio s3 对象存储

    minio 是一个aws s3 兼容的对象存储系统,我们可以通过s3fs 进行数据桶的挂载,这样可以做好多方便的事情 环境准备 使用docker-compose 运行 minio docker-com ...

  8. nexus && minio s3 存储私有镜像

    对于新版本的nexus 已经支持s3 存储了(3.12),但是企业内部可能还是需要使用私有部署的 还好我们有minio,具体的介绍就不说了 minio 项目运行 参考项目: https://githu ...

  9. cronicle minio s3 存储配置集成

    cronicle 后端存储是可配置的 ,通过使用不同的存储配置,我们可以解决多实例部署以及数据共享的问题 cronicle 的后端存储模型,设计的特别方便,包含了基于文件的,基于s3 的,同时我们也可 ...

随机推荐

  1. Java 安装后的检测是否安装成功

    下载安装JDK(Java SE development Kit) Java是有sun公司发行的编程语言,JDK的官方下载地址为:http\\ java.sun.com 昨天选择下载的是jdk-8u10 ...

  2. VSTO:使用C#开发Excel、Word【3】

    <Visual Studio Tools for Office: Using C# with Excel, Word, Outlook, and InfoPath >——By Eric C ...

  3. cv::ACCESS_MASK指定不明确的错误

    今天想实现在opencv下使用模拟按键,结果出现cv::ACCESS_MASK指定不明确的错误,查找得到如下原因: 在winnt.h里面有一个cv的命名空间,同样定义了一个ACCESS_MASK,跟o ...

  4. 2.14 C++析构函数

    参考: http://www.weixueyuan.net/view/6345.html 总结: 析构函数就是用于回收创建对象时所消耗的各种资源. 析构函数的调用顺序与构造函数调用顺序正好是相反的. ...

  5. CentOS7安装配置Bacular

    参考: http://blog.51cto.com/molewan/2045602 https://blog.csdn.net/heshangkung/article/details/47955023 ...

  6. 集成学习-xgboost

    等同于xgboost是个准曲率很高的集成学习框架,在很多比赛中成绩优异. 大多数的集成学习都使用决策树作为基分类器,主要是因为本身要训练多个分类器,而决策树速度很快,总体时间相对较少. 决策树 在讲x ...

  7. Oracle学习(二)_多表操作

    --第一部分:SQL基础 --ch1 简单查询 --ch2 查询基本概念 --ch3 数据过滤 --第二部分:多表操作 --ch4 集合理论 --ch5 内连接 --ch6 外连接 --ch7 子查询 ...

  8. 转--让一个运行在SYSTEM权限下的进程与当前用户的桌面进行交互

    #define DESKTOP_ALL ( DESKTOP_READOBJECTS | DESKTOP_CreateWINDOW | \ DESKTOP_CreateMENU | DESKTOP_HO ...

  9. dos命令:目录操作

    目录操作 一.cd语句 1.介绍 ​ 显示当前目录名或改变当前目录. 2.语法 CHDIR [/D] [drive:][path] CHDIR [..] CD [/D] [drive:][path] ...

  10. ksort 函数

    foreach ($modules AS $key => $value){ ksort($modules[$key]);}ksort($modules); strpos(','.$_SESSIO ...