使用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 的,同时我们也可 ...
随机推荐
- 每天CSS学习之box-shadow
box-shadow是CSS3的属性,目的是给盒子添加一个或多个阴影.怎么感觉有点像光明使者使用该法术照亮敌人的阴暗面? box-shadow一共有六个属性,请看: box-shadow: h-sha ...
- angular4-http
导入 Http 模块 import { HttpModule } from '@angular/http'; @NgModule({ imports: [BrowserModule, FormsMod ...
- linux 清空文件
将Linux文件清空的几种方法 1.使用重定向的方法 [root@centos7 ~]# du -h test.txt 4.0K test.txt [root@centos7 ~]# > tes ...
- Asp.Net对Json字符串的解析和应用
using System.Web.Script.Serialization; protected void Page_Load(object sender,EventArgs e) { //构建jso ...
- python3:利用SMTP协议发送QQ邮件+附件
转载请表明出处:https://www.cnblogs.com/shapeL/p/9115887.html 1.发送QQ邮件,首先必须知道QQ邮箱的SMTP服务器 http://service.mai ...
- 【Python】Excel操作-1
#练习:创建Excel 如果要创建的Excel已经存在并打开,会报错 from openpyxl import Workbook wb=Workbook() #创建文件对象 ws=wb.active ...
- async/await学习笔记
async/await 的目的是简化使用 promises 的写法. 让我们来看看下面的例子: // 一个标准的 JavaScript 函数 function getNumber1() { r ...
- Nginx 浏览器打开是下载状态
location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_inf ...
- LOD,听起来很牛逼的样子
<!DOCTYPE html> <html lang="en"> <head> <title>three.js webgl - le ...
- Pacman命令介绍
用pacman很久了,一直没有深入去研究到底它包含多少神秘的力量,每次都是pacman -Syu就简单的把所有升级更新问题搞定实在是让笔者懒惰了很多.不过也正是因为pacman的简单让笔者爱不释手,同 ...