-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevents persistent diff with option to deploy lambda from s3 package (…
…#83) * Prevents persistent diff with option to deploy lambda from s3 package Fixes #82 * Adds example for deploying lambda from s3 package * Updates readme using terraform-docs * Formats code using terraform fmt -recursive * Includes version in key as change detection mechanism for lambda * Adds a test to exercise the s3-hosted autoscaler binary * Removes example variables in response to feedback * Updates module version to 2.4.0 * Sets region in test config
- Loading branch information
1 parent
4a701c3
commit 39f3809
Showing
7 changed files
with
132 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
data "aws_vpc" "this" { | ||
default = true | ||
} | ||
|
||
data "aws_security_group" "this" { | ||
name = "default" | ||
vpc_id = data.aws_vpc.this.id | ||
} | ||
|
||
data "aws_subnets" "this" { | ||
filter { | ||
name = "vpc-id" | ||
values = [data.aws_vpc.this.id] | ||
} | ||
} | ||
|
||
#### Spacelift worker pool #### | ||
|
||
module "this" { | ||
source = "../../" | ||
|
||
configuration = <<-EOT | ||
export SPACELIFT_TOKEN="<token-here>" | ||
export SPACELIFT_POOL_PRIVATE_KEY="<private-key-here>" | ||
EOT | ||
security_groups = [data.aws_security_group.this.id] | ||
spacelift_api_key_endpoint = var.spacelift_api_key_endpoint | ||
spacelift_api_key_id = var.spacelift_api_key_id | ||
spacelift_api_key_secret = var.spacelift_api_key_secret | ||
vpc_subnets = data.aws_subnets.this.ids | ||
worker_pool_id = var.worker_pool_id | ||
|
||
enable_autoscaling = true | ||
autoscaler_s3_package = { | ||
bucket = aws_s3_bucket.autoscaler_binary.id | ||
key = aws_s3_object.autoscaler_binary.id | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# This is just a toy example config that pulls the autoscaler binary from GitHub | ||
# and hosts it in S3. This setup allows a simple plan/apply to work directly on | ||
# the example. In actual usage, it would not be recommended to abuse the http data | ||
# source and aws_s3_object resource in this manner. Instead, use an external process | ||
# to host the binary in your own S3 bucket. | ||
|
||
resource "aws_s3_bucket" "autoscaler_binary" { | ||
bucket_prefix = "spacelift-autoscaler-example-" | ||
} | ||
|
||
data "http" "autoscaler_binary" { | ||
url = "https://github.com/spacelift-io/ec2-workerpool-autoscaler/releases/download/${var.autoscaler_version}/ec2-workerpool-autoscaler_linux_${var.autoscaler_architecture}.zip" | ||
} | ||
|
||
resource "aws_s3_object" "autoscaler_binary" { | ||
key = "releases/download/${var.autoscaler_version}/ec2-workerpool-autoscaler_linux_${var.autoscaler_architecture}.zip" | ||
bucket = aws_s3_bucket.autoscaler_binary.id | ||
content_base64 = data.http.autoscaler_binary.response_body_base64 | ||
content_type = "application/octet-stream" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
variable "spacelift_api_key_id" { | ||
type = string | ||
description = "ID of the Spacelift API key to use" | ||
} | ||
|
||
variable "spacelift_api_key_secret" { | ||
type = string | ||
sensitive = true | ||
description = "Secret corresponding to the Spacelift API key to use" | ||
} | ||
|
||
variable "spacelift_api_key_endpoint" { | ||
type = string | ||
description = "Full URL of the Spacelift API endpoint to use, eg. https://demo.app.spacelift.io" | ||
} | ||
|
||
variable "worker_pool_id" { | ||
type = string | ||
description = "ID (ULID) of the the worker pool." | ||
} | ||
|
||
variable "autoscaler_version" { | ||
description = "Version of the autoscaler to deploy" | ||
type = string | ||
default = "v0.3.0" | ||
nullable = false | ||
} | ||
|
||
variable "autoscaler_architecture" { | ||
type = string | ||
description = "Instruction set architecture of the autoscaler to use" | ||
default = "amd64" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters