terraform-provider-matrix

git clone git://archive.git.mtrnord.blog/MTRNord/terraform-provider-matrix.git
Log | Files | Refs | README | LICENSE

main.tf (2522B)


      1 terraform {
      2   required_providers {
      3     matrix = {
      4       source = "mtrnord/matrix"
      5     }
      6   }
      7 }
      8 
      9 provider "matrix" {
     10   # The client/server URL to access your matrix homeserver with.
     11   # Environment variable: MATRIX_CLIENT_SERVER_URL
     12   client_server_url = "https://matrix.org"
     13 
     14   # The default access token to use for things like content uploads.
     15   # Does not apply for provisioning users.
     16   # Environment variable: MATRIX_DEFAULT_ACCESS_TOKEN
     17   default_access_token = "MDAxSomeRandomString"
     18 
     19   # The default userID to use for things like content uploads.
     20   # Must match the user that owns the default_access_token.
     21   # Does not apply for provisioning users.
     22   # Environment variable: MATRIX_DEFAULT_USERID
     23   default_user_id = "@meow:matrix.org"
     24 }
     25 
     26 # # Existing media 
     27 # resource "matrix_content" "catpic" {
     28 #     # Your MXC URI must fit the following format/example: 
     29 #     #   Format:   mxc://origin/media_id
     30 #     #   Example:  mxc://matrix.org/SomeGeneratedId
     31 #     origin = "matrix.org"
     32 #     media_id = "SomeGeneratedId"
     33 # }
     34 
     35 # # New media (upload)
     36 # resource "matrix_content" "catpic" {
     37 #     file_path = "/path/to/cat_pic.png"
     38 #     file_name = "cat_pic.png"
     39 #     file_type = "image/png"
     40 # }
     41 
     42 # # Username/password user
     43 # resource "matrix_user" "foouser" {
     44 #     username = "foouser"
     45 #     password = "hunter2"
     46 
     47 #     # These properties are optional, and will update the user's profile
     48 #     # We're using a reference to the Media used in an earlier example
     49 #     display_name = "My Cool User"
     50 #     avatar_mxc = "${matrix_content.catpic.id}"
     51 # }
     52 
     53 # Access token user
     54 resource "matrix_user" "baruser" {
     55   access_token = "MDAxOtherCharactersHere"
     56 
     57   # These properties are optional, and will update the user's profile
     58   # We're using a reference to the Media used in an earlier example
     59   display_name = "My Cool User"
     60   avatar_mxc   = matrix_content.catpic.id
     61 }
     62 
     63 # # Already existing room
     64 # resource "matrix_room" "fooroom" {
     65 #     room_id = "!somewhere:domain.com"
     66 #     member_access_token = "${matrix_user.foouser.access_token}"
     67 # }
     68 
     69 # New room
     70 resource "matrix_room" "barroom" {
     71   creator_user_id     = matrix_user.foouser.id
     72   member_access_token = matrix_user.foouser.access_token
     73 
     74   # The rest is optional
     75   name                  = "My Room"
     76   avatar_mxc            = matrix_content.catpic.id
     77   topic                 = "For testing only please"
     78   preset                = "public_chat"
     79   guests_allowed        = true
     80   invite_user_ids       = ["${matrix_user.baruser.id}"]
     81   local_alias_localpart = "myroom"
     82 }
     83