使用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 的,同时我们也可 ...
随机推荐
- C++输出数组名
1.如果C++输出的数组是char类型的,那么输出的就是数组中的元素. 2.如果使用的是其他类型的数组作为输出的话,那么就是一个16进制的地址. 3.还是那句话,对数组的操作,很多时候都是指针的操作, ...
- bootstrap table 列求和
<div class="modal fade in" id="_modalDialog" tabindex="1" role=&quo ...
- 20165326 java第二周学习笔记
学习笔记 一.理论学习 基本数据类型与数组 标识符的第一个字符不能是数字:标识符不能为关键字. 基本数据类型多数与c语言相同.重点如下: 1.逻辑类型boolean赋值true/false 2.浮点数 ...
- TextRank算法
TextRank是一种用来做关键词提取的算法,也可以用于提取短语和自动摘要.因为TextRank是基于PageRank的,所以首先简要介绍下PageRank算法. (1)PageRank PageRa ...
- python基础题型一
一.执行Python脚本的两种方式 #python name.py Python解析器 #chmod +x name.py 二.简述位.字节的关系 1Byte=8bit 三.简述ascii.uni ...
- Windows 窗体设计器生成的代码
namespace 窗体的浮动及隐藏{ partial class Form1 { /// <summary> /// 必需的设计器变量. ...
- Metasploit的射频收发器功能 | Metasploit’s RF Transceiver Capabilities
https://community.rapid7.com/community/metasploit/blog/2017/03/21/metasploits-rf-transceiver-capabil ...
- Python 字符串操作方法大全
Python 字符串操作方法大全 1.去空格及特殊符号复制代码代码如下:s.strip().lstrip().rstrip(',') 2.复制字符串复制代码代码如下:#strcpy(sStr1,sSt ...
- Python 内置函数2
print(list("胡辣汤")) lst = ["河南话", "四川话", "东北", "山东" ...
- ES6 对象的扩展 Object.assign()
Object.assign方法用于对象的合并,将源对象(source)的所有可枚举属性,复制到目标对象(target). const target = { a: 1 }; const source1 ...