|
| 1 | +# terraform-provider-mcbroken <img src="https://i.imgur.com/fAS7XqO.png" height="5%" width="5%" align="left"/> |
| 2 | + |
| 3 | + |
| 4 | +[](https://goreportcard.com/report/github.com/circa10a/terraform-provider-mcbroken) |
| 5 | + |
| 6 | +[](https://www.buymeacoffee.com/caleblemoine) |
| 7 | + |
| 8 | +Base the count of your infrastucture resources on the national average of broken mcdonald's ice machines or by a city of your choosing. Powered by [Mcbroken](https://mcbroken.com/). |
| 9 | + |
| 10 | +- [terraform-provider-mcbroken](#terraform-provider-mcbroken) |
| 11 | + * [Usage](#usage) |
| 12 | + * [Development](#development) |
| 13 | + + [Linting](#linting) |
| 14 | + + [Mac](#mac) |
| 15 | + + [Linux](#linux) |
| 16 | + + [Windows](#windows) |
| 17 | + |
| 18 | +## Usage |
| 19 | + |
| 20 | +```terraform |
| 21 | +provider "mcbroken" {} |
| 22 | +
|
| 23 | +// Data source to get all available cities/national average of broken ice cream machines |
| 24 | +data "mcbroken_cities" "all" {} |
| 25 | +// Data source to get current outage percentage of a specific city |
| 26 | +data "mcbroken_city" "Dallas" { |
| 27 | + city = "Dallas" |
| 28 | +} |
| 29 | +// If specified city isn't found, returns -1 |
| 30 | +data "mcbroken_city" "not_found" { |
| 31 | + city = "not_found" |
| 32 | +} |
| 33 | +// Get national average of broken ice cream machines |
| 34 | +output "global_broken_average" { |
| 35 | + value = data.mcbroken_cities.all.broken |
| 36 | +} |
| 37 | +// Get list of all cities and their outage percentage |
| 38 | +output "all_available_cities" { |
| 39 | + value = data.mcbroken_cities.all.cities |
| 40 | +} |
| 41 | +// Get outage percentage of a specific city |
| 42 | +output "user_specified_city" { |
| 43 | + value = data.mcbroken_city.Dallas.broken |
| 44 | +} |
| 45 | +// When user specified city isn't found, return -1 |
| 46 | +output "user_specified_city_not_found" { |
| 47 | + value = data.mcbroken_city.not_found.broken |
| 48 | +} |
| 49 | +
|
| 50 | +# Apply complete! Resources: 0 added, 0 changed, 0 destroyed. |
| 51 | +
|
| 52 | +# Outputs: |
| 53 | +
|
| 54 | +# all_available_cities = [ |
| 55 | +# { |
| 56 | +# "broken" = 13.04 |
| 57 | +# "city" = "New York" |
| 58 | +# }, |
| 59 | +# { |
| 60 | +# "broken" = 13.04 |
| 61 | +# "city" = "San diego" |
| 62 | +# }, |
| 63 | +# { |
| 64 | +# "broken" = 12.5 |
| 65 | +# "city" = "Philadelphia" |
| 66 | +# }, |
| 67 | +# { |
| 68 | +# "broken" = 11.11 |
| 69 | +# "city" = "Boston" |
| 70 | +# }, |
| 71 | +# { |
| 72 | +# "broken" = 10.81 |
| 73 | +# "city" = "Washington" |
| 74 | +# }, |
| 75 | +# { |
| 76 | +# "broken" = 10.53 |
| 77 | +# "city" = "Los Angeles" |
| 78 | +# }, |
| 79 | +# { |
| 80 | +# "broken" = 9.88 |
| 81 | +# "city" = "Chicago" |
| 82 | +# }, |
| 83 | +# { |
| 84 | +# "broken" = 8.51 |
| 85 | +# "city" = "Phoenix" |
| 86 | +# }, |
| 87 | +# { |
| 88 | +# "broken" = 8.11 |
| 89 | +# "city" = "Dallas" |
| 90 | +# }, |
| 91 | +# { |
| 92 | +# "broken" = 8.05 |
| 93 | +# "city" = "Houston" |
| 94 | +# }, |
| 95 | +# { |
| 96 | +# "broken" = 7.41 |
| 97 | +# "city" = "San Jose" |
| 98 | +# }, |
| 99 | +# { |
| 100 | +# "broken" = 6.67 |
| 101 | +# "city" = "San Francisco" |
| 102 | +# }, |
| 103 | +# { |
| 104 | +# "broken" = 3.77 |
| 105 | +# "city" = "San antonio" |
| 106 | +# }, |
| 107 | +# { |
| 108 | +# "broken" = 0 |
| 109 | +# "city" = "Seattle" |
| 110 | +# }, |
| 111 | +# ] |
| 112 | +# global_broken_average = 7.45 |
| 113 | +# user_specified_city = 8.11 |
| 114 | +# user_specified_city_not_found = -1 |
| 115 | +``` |
| 116 | + |
| 117 | +## Development |
| 118 | + |
| 119 | +### Linting |
| 120 | + |
| 121 | +```bash |
| 122 | +make lint |
| 123 | +``` |
| 124 | + |
| 125 | +### Mac |
| 126 | + |
| 127 | +```bash |
| 128 | +make build-mac && \ |
| 129 | +cd examples && \ |
| 130 | +terraform init && \ |
| 131 | +terraform apply |
| 132 | +``` |
| 133 | + |
| 134 | +### Linux |
| 135 | + |
| 136 | +```bash |
| 137 | +make build-linux && \ |
| 138 | +cd examples && \ |
| 139 | +terraform init && \ |
| 140 | +terraform apply |
| 141 | +``` |
| 142 | + |
| 143 | +### Windows |
| 144 | + |
| 145 | + |
0 commit comments