使用terraform-provider-s3 操作minio
尽管默认官方提供了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的更多相关文章
- Write your own Terraform provider: Part 1
转自:https://container-solutions.com/write-terraform-provider-part-1/ This is the first part of a seri ...
- 四、C#简单操作MinIO
MinIO的官方网站非常详细,以下只是本人学习过程的整理 一.MinIO的基本概念 二.Windows安装与简单使用MinIO 三.Linux部署MinIO分布式集群 四.C#简单操作MinIO He ...
- 京东云携手HashiCorp,宣布推出Terraform Provider
2019年4月23日消息,京东云携手云基础设施自动化软件的领导者HashiCorp,宣布推出Terraform Provider for JD Cloud,这意味着用户能够在京东云上轻松使用简单模板语 ...
- drill 集成开源s3 存储minio
drill 支持s3数据的查询,同时新版的通过简单配置就可以实现minio 的集成 测试使用docker 运行drill 参考 https://www.cnblogs.com/rongfenglian ...
- Amazon AWS S3 操作手册
Install the SDK The recommended way to use the AWS SDK for Java in your project is to consume it fro ...
- content provider其中操作文件的函数
此类函数还是有杀伤力的 1.openAssetFile(Uri uri, String mode)This is like openFile(Uri, String), but can be impl ...
- 使用s3fs-fuse 挂载minio s3 对象存储
minio 是一个aws s3 兼容的对象存储系统,我们可以通过s3fs 进行数据桶的挂载,这样可以做好多方便的事情 环境准备 使用docker-compose 运行 minio docker-com ...
- nexus && minio s3 存储私有镜像
对于新版本的nexus 已经支持s3 存储了(3.12),但是企业内部可能还是需要使用私有部署的 还好我们有minio,具体的介绍就不说了 minio 项目运行 参考项目: https://githu ...
- cronicle minio s3 存储配置集成
cronicle 后端存储是可配置的 ,通过使用不同的存储配置,我们可以解决多实例部署以及数据共享的问题 cronicle 的后端存储模型,设计的特别方便,包含了基于文件的,基于s3 的,同时我们也可 ...
随机推荐
- Traumland--梦乡--IPA--德语
德国电影<<英俊少年>>的插曲.
- VBA续嘘嘘——宏技巧集绵
什么是VBA?它有什么作用? A.实现Excel中没有实现的功能. B.提高运行速度. C.编写自定义函数. D.实现自动化功能. E.通过插入窗体做小型管理软件. VBA在哪里存放的?怎么运行? A ...
- node(2) EventEmitter类 事件队列 事件和error事件方法
事件队列的核心:事件触发与事件监听器功能的封装. // 引入 events 模块 var events = require('events'); // 创建 eventEmitter 对象 var e ...
- Fedora的一些个人配置
0,老传统 yum install screenfetch 1,关闭蜂鸣器 edit /etc/bashrc setterm -blength 0#setterm -bfreq 10 #这个可以设置声 ...
- dubbo的几种配置方式(转)
昨天刚接触公司dubbo,发现公司中项目里面的spring-dubbo-privider的dubbo中<dubbo:application name=""/>和< ...
- codeforce949A(顺带vector详细使用介绍)
A. Zebras time limit per test1 second memory limit per test512 megabytes inputstandard input outputs ...
- Java学习笔记28(IO字节流)
IO定义: 写:Output操作:将内存上的数据持久化 到设备上,这个动作称为输出: 读:Input操作:把硬盘上的东西读取到内存,这个动作称为输入: 这两种操作称为IO流 ...
- PHP ueditor编辑器使用(TP5)
百度搜索ueditor,下载,解压,把需要的JS文件放到对应的目录里,根据框架的不同目录也不一样 在文件中引入需要的JS文件 HTML代码 <div> <!-- 编辑器 --> ...
- GB2312汉字编码字符集对照表
第01区 +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F A1A0 . . ・ ˉ ˇ ¨ " 々 ― - | - ' ' A1B0 &quo ...
- 性能测试-6.VUG脚本参数化
前言:(原文地址)版面调整 什么是VUGEN action以及作用 参数化 参数化取值(9种组合,在不同场景中如何运用) 一.VUGEN是 LoadRunner 用于开发 Vuser 脚本的主要工具. ...