scout-camp 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd5f35a6409cd8556f8fb6cb8641c28c36fb3b0dcc9110eeef8c8d9a5ea42594
4
- data.tar.gz: 7bb5e7f5b07ac7d9ca601909bc3c5632d6f9d1630020e308d901d8b3a771d0f5
3
+ metadata.gz: e451509a388ca0463eccc9609ef4e506cc793a6ee3df3c720ed441f806641c13
4
+ data.tar.gz: 3950a94e466395630140a5265f3351f8e482b7a983402488587f840af4f177d3
5
5
  SHA512:
6
- metadata.gz: e460301e94edf73163f57309498db7d04b38b202c0437938dc0bf10cb0a31e1683f8d908309b0876fe106e781f2b69e24563656562eb57e0a759116bfb38f904
7
- data.tar.gz: 6a78670a91b259399cad19a95411c214f3382173c37bb2611f4b13deb8a32a1626d0f2dfb793e8462253e6322156b104816a0bc5f3f37ce9d0cf3017bf735adf
6
+ metadata.gz: 96ee495972e08312e7b1f9ed10e8e47d7f72983d554b3113c17967c5080a20ec01ff6317939da97e90cb5db6b5b2ad2ffd9aeb2cf7fb092e3e8a2faaadc0543b
7
+ data.tar.gz: 16daf0c75fbe0028eaf44d5be4a174f2de7ad05866568fd27e1376851397e4c493607bdce1e03f8943e47b22a7533dfe13599c7f10126a3e60f3b6dfe20f226b
data/.vimproject CHANGED
@@ -19,19 +19,24 @@ scout-camp=/$PWD filter="*" {
19
19
  ssh.rb
20
20
  step.rb
21
21
  sync.rb
22
+ resource.rb
22
23
  }
23
24
  }
24
25
  }
25
26
  scout_commands=scout_commands {
26
27
  offsite
28
+ sync
29
+
27
30
  terraform=terraform{
28
31
  list
29
32
  add=add{
30
- lambda
31
33
  relay
34
+ lambda
35
+ host
36
+ fargate
32
37
  }
33
- add
34
38
  status
39
+ outputs
35
40
  apply
36
41
  plan
37
42
  destroy
@@ -42,15 +47,46 @@ scout-camp=/$PWD filter="*" {
42
47
  share=share {
43
48
  terraform=terraform {
44
49
  aws=aws {
50
+ fargate=fargate{
51
+ main.tf
52
+ variables.tf
53
+ locals.tf
54
+ }
55
+
56
+ efs_host=efs_host{
57
+ main.tf
58
+ variables.tf
59
+ locals.tf
60
+ data.tf
61
+ output.tf
62
+ }
63
+
64
+ efs=efs{
65
+ main.tf
66
+ variables.tf
67
+ data.tf
68
+ locals.tf
69
+ output.tf
70
+ }
71
+
72
+ network=network{
73
+ data.tf
74
+ main.tf
75
+ variables.tf
76
+ output.tf
77
+ }
78
+
45
79
  bucket=bucket {
46
80
  main.tf
47
81
  output.tf
48
82
  variables.tf
49
83
  }
84
+
50
85
  lambda=lambda {
51
86
  main.tf
52
87
  variables.tf
53
88
  }
89
+
54
90
  role=role{
55
91
  main.tf
56
92
  variables.tf
@@ -71,11 +107,6 @@ scout-camp=/$PWD filter="*" {
71
107
  output.tf
72
108
  variables.tf
73
109
  }
74
- fargate=fargate{
75
- locals.tf
76
- main.tf
77
- variables.tf
78
- }
79
110
  provider=provider {
80
111
  data.tf
81
112
  output.tf
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.6
1
+ 0.1.8
@@ -0,0 +1,34 @@
1
+ require 'scout/resource'
2
+ require_relative 'sync'
3
+ module Resource
4
+ def self.sync(path, map = nil, source: nil, target: nil, resource: nil, **kwargs)
5
+ map = 'user' if map.nil?
6
+
7
+ if source
8
+ paths = [path]
9
+ real_paths, identified_paths = SSHLine.locate(source, paths)
10
+ else
11
+ resource = path.pkgdir if resource.nil? and path.is_a?(Path) and path.pkgdir.is_a?(Resource)
12
+ resource = Resource.default_resource if resource.nil?
13
+
14
+ if File.exist?(path)
15
+ real_paths = [path]
16
+ else
17
+ path = Path.setup(path, pkgdir: resource) unless path.is_a?(Path)
18
+ real_paths = path.directory? ? path.find_all : path.glob_all
19
+ end
20
+
21
+ identified_paths = real_paths.collect{|path| resource.identify(path) }
22
+ end
23
+
24
+ if target
25
+ target_paths = SSHLine.locate(target, identified_paths, map: map)
26
+ else
27
+ target_paths = identified_paths.collect{|p| p.find(map) }
28
+ end
29
+
30
+ real_paths.zip(target_paths).each do |source_path,target_path|
31
+ Open.sync(source_path, target_path, kwargs.merge(source: source, target: target))
32
+ end
33
+ end
34
+ end
@@ -1,4 +1,5 @@
1
1
  require 'net/ssh'
2
+ require 'scout/persist'
2
3
  require_relative 'exceptions'
3
4
 
4
5
  class SSHLine
@@ -90,6 +91,7 @@ class SSHLine
90
91
  def scout(script)
91
92
  scout_script =<<-EOF
92
93
  require 'scout'
94
+ require 'scout/offsite/ssh'
93
95
  SSHLine.run_local do
94
96
  #{script.strip}
95
97
  end
@@ -1,3 +1,4 @@
1
+ require_relative 'ssh'
1
2
  class SSHLine
2
3
  def self.locate(server, paths, map: :user)
3
4
  SSHLine.scout server, <<-EOF
@@ -5,6 +6,7 @@ map = :#{map}
5
6
  paths = [#{paths.collect{|p| "'" + p + "'" } * ", " }]
6
7
  located = paths.collect{|p| Path.setup(p).find(map) }
7
8
  identified = paths.collect{|p| Resource.identify(p) }
9
+ located = located.collect{|path| path << "/" if path.directory? }
8
10
  [located, identified]
9
11
  EOF
10
12
  end
@@ -13,9 +13,9 @@ class TerraformDSL
13
13
  # @param prefix [nil,String] Optional prefix to prepend
14
14
  def self.log(msg, prefix = nil)
15
15
  if prefix
16
- STDOUT.puts("[#{prefix}] " + msg)
16
+ Log.info("[#{prefix}] " + msg)
17
17
  else
18
- STDOUT.puts(msg)
18
+ Log.info(msg)
19
19
  end
20
20
  end
21
21
 
@@ -80,7 +80,12 @@ class TerraformDSL
80
80
  def to_json(*_args)
81
81
  ['module', @name].join('.')
82
82
  end
83
+ end
83
84
 
85
+ module DirectReference
86
+ def to_json(*_args)
87
+ self
88
+ end
84
89
  end
85
90
 
86
91
  MODULES_DIR = Scout.share.terraform
@@ -180,6 +185,52 @@ class TerraformDSL
180
185
  nil
181
186
  end
182
187
 
188
+ # Add a backend template file without using modules.
189
+ #
190
+ # @param variables [Hash] variables for the backend:
191
+ # :bucket, :key & :region
192
+ def backend(type, variables = {})
193
+ variables = variables.dup
194
+
195
+ text =<<~EOF
196
+ terraform {
197
+ backend "#{type}" {
198
+ #{variable_block(variables)}
199
+ }
200
+ }
201
+ EOF
202
+
203
+ element_file = ['backend_config', type.to_s].join('.')
204
+
205
+ custom(element_file, text)
206
+
207
+ nil
208
+ end
209
+
210
+ # Connect to a remote state through a backend
211
+ #
212
+ # @param variables [Hash] variables for the backend:
213
+ # :bucket, :key & :region
214
+ def remote(type, key, variables = {})
215
+ variables = variables.dup
216
+ variables[:key] = key unless variables.include?(:key)
217
+
218
+ text =<<~EOF
219
+ data "terraform_remote_state" "#{key}" {
220
+ backend = "#{type}"
221
+ config = {
222
+ #{variable_block(variables)}
223
+ }
224
+ }
225
+ EOF
226
+
227
+ element_file = ['remote', type.to_s, key.to_s].join('.')
228
+
229
+ custom(element_file, text)
230
+
231
+ "data.terraform_remote_state.#{key}".extend DirectReference
232
+ end
233
+
183
234
  # Add a provider template file without using modules.
184
235
  # Defining providers in modules is problematic when providers
185
236
  # are not managed by Hashicorp. Hopefully we can
data/scout-camp.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: scout-camp 0.1.6 ruby lib
5
+ # stub: scout-camp 0.1.8 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "scout-camp".freeze
9
- s.version = "0.1.6".freeze
9
+ s.version = "0.1.8".freeze
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Miguel Vazquez".freeze]
14
- s.date = "2025-04-08"
14
+ s.date = "1980-01-02"
15
15
  s.description = "Functionalities to deploy and use scouts in remote servers like AWS".freeze
16
16
  s.email = "mikisvaz@gmail.com".freeze
17
17
  s.executables = ["scout-camp".freeze]
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
30
30
  "lib/scout/aws/s3.rb",
31
31
  "lib/scout/offsite.rb",
32
32
  "lib/scout/offsite/exceptions.rb",
33
+ "lib/scout/offsite/resource.rb",
33
34
  "lib/scout/offsite/ssh.rb",
34
35
  "lib/scout/offsite/step.rb",
35
36
  "lib/scout/offsite/sync.rb",
@@ -38,12 +39,14 @@ Gem::Specification.new do |s|
38
39
  "lib/scout/terraform_dsl/util.rb",
39
40
  "scout-camp.gemspec",
40
41
  "scout_commands/offsite",
42
+ "scout_commands/sync",
41
43
  "scout_commands/terraform/add/lambda",
42
44
  "scout_commands/terraform/add/relay",
43
45
  "scout_commands/terraform/apply",
44
46
  "scout_commands/terraform/destroy",
45
47
  "scout_commands/terraform/lambda_task",
46
48
  "scout_commands/terraform/list",
49
+ "scout_commands/terraform/outputs",
47
50
  "scout_commands/terraform/plan",
48
51
  "scout_commands/terraform/remove",
49
52
  "scout_commands/terraform/status",
@@ -55,12 +58,29 @@ Gem::Specification.new do |s|
55
58
  "share/terraform/aws/cluster/main.tf",
56
59
  "share/terraform/aws/cluster/output.tf",
57
60
  "share/terraform/aws/cluster/variables.tf",
61
+ "share/terraform/aws/efs/data.tf",
62
+ "share/terraform/aws/efs/locals.tf",
63
+ "share/terraform/aws/efs/main.tf",
64
+ "share/terraform/aws/efs/output.tf",
65
+ "share/terraform/aws/efs/variables.tf",
66
+ "share/terraform/aws/efs_host/data.tf",
67
+ "share/terraform/aws/efs_host/locals.tf",
68
+ "share/terraform/aws/efs_host/main.tf",
69
+ "share/terraform/aws/efs_host/output.tf",
70
+ "share/terraform/aws/efs_host/variables.tf",
71
+ "share/terraform/aws/fargate/locals.tf",
72
+ "share/terraform/aws/fargate/main.tf",
73
+ "share/terraform/aws/fargate/variables.tf",
58
74
  "share/terraform/aws/host/locals.tf",
59
75
  "share/terraform/aws/host/main.tf",
60
76
  "share/terraform/aws/host/output.tf",
61
77
  "share/terraform/aws/host/variables.tf",
62
78
  "share/terraform/aws/lambda/main.tf",
63
79
  "share/terraform/aws/lambda/variables.tf",
80
+ "share/terraform/aws/network/data.tf",
81
+ "share/terraform/aws/network/main.tf",
82
+ "share/terraform/aws/network/output.tf",
83
+ "share/terraform/aws/network/variables.tf",
64
84
  "share/terraform/aws/policy_attachment/main.tf",
65
85
  "share/terraform/aws/policy_attachment/variables.tf",
66
86
  "share/terraform/aws/provider/data.tf",
@@ -71,6 +91,7 @@ Gem::Specification.new do |s|
71
91
  "share/terraform/ssh/cmd/main.tf",
72
92
  "share/terraform/ssh/cmd/variables.tf",
73
93
  "test/scout/aws/test_s3.rb",
94
+ "test/scout/offsite/test_resource.rb",
74
95
  "test/scout/offsite/test_ssh.rb",
75
96
  "test/scout/offsite/test_step.rb",
76
97
  "test/scout/offsite/test_sync.rb",
@@ -79,7 +100,7 @@ Gem::Specification.new do |s|
79
100
  ]
80
101
  s.homepage = "http://github.com/mikisvaz/scout-camp".freeze
81
102
  s.licenses = ["MIT".freeze]
82
- s.rubygems_version = "3.6.5".freeze
103
+ s.rubygems_version = "3.6.7".freeze
83
104
  s.summary = "Deploy you scouts".freeze
84
105
 
85
106
  s.specification_version = 4
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'scout'
4
+ require 'scout/offsite/resource'
5
+
6
+ $0 = "scout #{$previous_commands.any? ? $previous_commands*" " + " " : "" }#{ File.basename(__FILE__) }" if $previous_commands
7
+
8
+ options = SOPT.setup <<EOF
9
+
10
+ Sync to resources between path maps or between hosts
11
+
12
+ $ #{$0} [<options>] <path> [<path_map>]
13
+
14
+ Path map defaults to :user
15
+
16
+ -h--help Print this help
17
+ -s--source* Host of source path
18
+ -t--target* Host of target path
19
+ EOF
20
+ if options[:help]
21
+ if defined? scout_usage
22
+ scout_usage
23
+ else
24
+ puts SOPT.doc
25
+ end
26
+ exit 0
27
+ end
28
+
29
+ path, path_map = ARGV
30
+
31
+ raise MissingParameterException, :path if path.nil?
32
+
33
+ Resource.sync(Path.setup(path.dup), path_map, **options)
@@ -25,12 +25,20 @@ end
25
25
  deployments = Scout.var.deployments.glob_all("*")
26
26
 
27
27
  deployments.each do |dir|
28
+ next unless File.directory?(dir)
28
29
  name = File.basename dir
29
30
  deployment = TerraformDSL::Deployment.new dir
30
- active = options[:active] && deployment.provisioned_elements.any?
31
+ #active = options[:active] && deployment.provisioned_elements.any?
31
32
 
32
- if active
33
- puts Log.color(:title, name ) + "\t" + dir + "\t" + "Active"
33
+ if options[:active]
34
+ Log.with_severity 5 do
35
+ print Log.color(:title, name ) + "\t" + dir + "\t"
36
+ if deployment.provisioned_elements.any?
37
+ puts Log.color :present, "Active"
38
+ else
39
+ puts Log.color :missing, "Inactive"
40
+ end
41
+ end
34
42
  else
35
43
  puts Log.color(:title, name) + "\t" + dir
36
44
  end
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'scout'
4
+
5
+ $0 = "scout #{$previous_commands.any? ? $previous_commands*" " + " " : "" }#{ File.basename(__FILE__) }" if $previous_commands
6
+
7
+ options = SOPT.setup <<EOF
8
+
9
+ Work with deployment
10
+
11
+ $ #{$0} [<options>] <name>
12
+
13
+ -h--help Print this help
14
+ EOF
15
+ if options[:help]
16
+ if defined? scout_usage
17
+ scout_usage
18
+ else
19
+ puts SOPT.doc
20
+ end
21
+ exit 0
22
+ end
23
+
24
+ name = ARGV.shift
25
+ raise MissingParameterException, :name if name.nil?
26
+
27
+ dir = Scout.var.deployments.glob_all(name).first
28
+
29
+ deployment = TerraformDSL::Deployment.new dir
30
+ deployment.provisioned_elements.each do |element|
31
+ ppp deployment.element_state(element)
32
+ end
33
+
@@ -7,11 +7,11 @@ def lambda_handler(event:, context:)
7
7
  require 'scout/workflow'
8
8
  require 'scout/aws/s3'
9
9
 
10
- workflow, task_name, jobname, inputs = IndiferentHash.process_options event,
11
- :workflow, :task_name, :jobname, :inputs
12
-
10
+ workflow, task_name, jobname, inputs, clean = IndiferentHash.process_options event,
11
+ :workflow, :task_name, :jobname, :inputs, :clean
12
+
13
13
  raise ParamterException, "No workflow specified" if workflow.nil?
14
-
14
+
15
15
  workflow = Workflow.require_workflow workflow
16
16
 
17
17
  case task_name
@@ -22,6 +22,16 @@ def lambda_handler(event:, context:)
22
22
  return workflow.task_info(inputs["task_name"])
23
23
  else
24
24
  job = workflow.job(task_name, jobname, inputs)
25
- job.run
25
+
26
+ case clean
27
+ when true, 'true'
28
+ job.clean
29
+ when 'recursive'
30
+ job.recursive_clean
31
+ end
32
+
33
+ job.produce
34
+
35
+ job.load
26
36
  end
27
37
  end
@@ -0,0 +1,12 @@
1
+ # Get default VPC (optional if you want to restrict to default VPC)
2
+ data "aws_vpc" "default" {
3
+ default = true
4
+ }
5
+
6
+ # Get all subnets in the region (filtered to default VPC if needed)
7
+ data "aws_subnets" "all" {
8
+ filter {
9
+ name = "vpc-id"
10
+ values = [data.aws_vpc.default.id]
11
+ }
12
+ }
@@ -0,0 +1,6 @@
1
+ locals {
2
+ security_group_ids = [
3
+ for sg_key in var.sg_keys :
4
+ lookup(var.remote.outputs, sg_key, null)
5
+ ]
6
+ }
@@ -0,0 +1,14 @@
1
+ resource "aws_efs_file_system" "this" {
2
+ creation_token = "herlab-efs"
3
+ tags = {
4
+ Name = "HERLab main EFS"
5
+ }
6
+ }
7
+
8
+ resource "aws_efs_mount_target" "this" {
9
+ for_each = toset(data.aws_subnets.all.ids)
10
+
11
+ file_system_id = aws_efs_file_system.this.id
12
+ subnet_id = each.value
13
+ security_groups = local.security_group_ids
14
+ }
@@ -0,0 +1,3 @@
1
+ output "id" {
2
+ value = aws_efs_file_system.this.id
3
+ }
@@ -0,0 +1,9 @@
1
+ variable "remote" {
2
+ description = "Name of the remote state block to use"
3
+ }
4
+
5
+ variable "sg_keys" {
6
+ description = "List of output names in the remote state representing security group IDs"
7
+ type = list(string)
8
+ default = ["aws_network_efs_sg_id"]
9
+ }
@@ -0,0 +1,11 @@
1
+ data "aws_ami" "amazon_linux_2" {
2
+ most_recent = true
3
+ owners = ["amazon"]
4
+
5
+ # Filter for Amazon Linux 2 AMIs
6
+ filter {
7
+ name = "name"
8
+ values = ["amzn2-ami-hvm-*-x86_64-gp2"]
9
+ }
10
+ }
11
+
@@ -0,0 +1,8 @@
1
+ locals {
2
+ security_group_ids = [
3
+ for sg_key in var.sg_keys :
4
+ lookup(var.network.outputs, sg_key, null)
5
+ ]
6
+
7
+ efs_id = lookup(var.efs.outputs, "aws_efs_id", null)
8
+ }
@@ -0,0 +1,31 @@
1
+ resource "aws_key_pair" "this" {
2
+ key_name = "my-key"
3
+ public_key = file("~/.ssh/id_rsa.pub") # Adjust if your key is elsewhere
4
+ }
5
+
6
+ resource "aws_instance" "this" {
7
+ ami = data.aws_ami.amazon_linux_2.id
8
+ instance_type = "t2.micro"
9
+
10
+ key_name = aws_key_pair.this.key_name
11
+
12
+ tags = {
13
+ Name = "EFS-Service"
14
+ }
15
+
16
+ # Open port 22 for SSH
17
+ vpc_security_group_ids = local.security_group_ids
18
+
19
+ user_data = <<-EOF
20
+ #cloud-config
21
+ package_update: true
22
+ package_upgrade: true
23
+ packages:
24
+ - amazon-efs-utils
25
+ runcmd:
26
+ - mkdir -p /mnt/efs
27
+ - mount -t efs -o tls ${local.efs_id}:/ ${var.mount_point}
28
+ - echo "${local.efs_id}:/ ${var.mount_point} efs defaults,_netdev 0 0" >> /etc/fstab
29
+ EOF
30
+ }
31
+
@@ -0,0 +1,3 @@
1
+ output "public_ip" {
2
+ value = aws_instance.this.public_ip
3
+ }
@@ -0,0 +1,20 @@
1
+ variable "network" {
2
+ description = "Name of the remote state block to use for the network"
3
+ }
4
+
5
+ variable "efs" {
6
+ description = "Name of the remote state block to use for the EFS"
7
+ }
8
+
9
+ variable "sg_keys" {
10
+ description = "List of output names in the remote state representing security group IDs"
11
+ type = list(string)
12
+ default = ["aws_network_efs_sg_id", "aws_network_ssh_sg_id"]
13
+ }
14
+
15
+ variable "mount_point" {
16
+ description = "Where to mount the efs drive"
17
+ type = string
18
+ default = "/mnt/efs"
19
+ }
20
+
@@ -0,0 +1,8 @@
1
+ locals {
2
+ security_group_ids = [
3
+ for sg_key in var.sg_keys :
4
+ lookup(var.network.outputs, sg_key, null)
5
+ ]
6
+
7
+ efs_id = lookup(var.efs.outputs, "aws_efs_id", null)
8
+ }
@@ -0,0 +1,38 @@
1
+ resource "aws_ecs_task_definition" "this" {
2
+ family = var.task_family
3
+ requires_compatibilities = ["FARGATE"]
4
+ network_mode = "awsvpc"
5
+ cpu = var.cpu
6
+ memory = var.memory
7
+ execution_role_arn = var.role_arn
8
+
9
+ container_definitions = jsonencode([
10
+ {
11
+ name = var.container_name
12
+ image = var.image
13
+ essential = true
14
+ portMappings = var.port_mappings
15
+ //entryPoint = var.entry_point
16
+ command = var.command
17
+
18
+ mountPoints = [
19
+ {
20
+ sourceVolume = "efs-volume"
21
+ containerPath = var.mount_point
22
+ }
23
+ ]
24
+ }
25
+ ])
26
+
27
+ volume {
28
+ name = "efs-volume"
29
+ efs_volume_configuration {
30
+ file_system_id = local.efs_id
31
+ root_directory = "/"
32
+ }
33
+ }
34
+ }
35
+
36
+ resource "aws_ecs_cluster" "this" {
37
+ name = "${var.task_family}_cluster"
38
+ }
@@ -0,0 +1,73 @@
1
+ variable "network" {
2
+ description = "Name of the remote state block to use for the network"
3
+ }
4
+
5
+ variable "efs" {
6
+ description = "Name of the remote state block to use for the EFS"
7
+ }
8
+
9
+ variable "sg_keys" {
10
+ description = "List of output names in the remote state representing security group IDs"
11
+ type = list(string)
12
+ default = ["aws_network_efs_sg_id", "aws_network_ssh_sg_id"]
13
+ }
14
+
15
+ variable "mount_point" {
16
+ description = "Where to mount the efs drive"
17
+ type = string
18
+ default = "/mnt/efs"
19
+ }
20
+
21
+ variable "task_family" {
22
+ type = string
23
+ description = "The family name of the ECS task definition"
24
+ }
25
+
26
+ variable "cpu" {
27
+ type = number
28
+ description = "The CPU units for the task"
29
+ default = 256
30
+ }
31
+
32
+ variable "memory" {
33
+ type = number
34
+ description = "The memory (MiB) for the task"
35
+ default = 512
36
+ }
37
+
38
+ variable "role_arn" {
39
+ type = string
40
+ description = "ARN of the task execution role"
41
+ }
42
+
43
+ variable "container_name" {
44
+ type = string
45
+ description = "Name of the container"
46
+ default = "app"
47
+ }
48
+
49
+ variable "image" {
50
+ type = string
51
+ description = "Docker image URL for the container"
52
+ }
53
+
54
+ variable "port_mappings" {
55
+ type = list(object({
56
+ containerPort = number
57
+ hostPort = number
58
+ protocol = string
59
+ }))
60
+ description = "List of port mappings for the container"
61
+ default = []
62
+ }
63
+
64
+ variable "command" {
65
+ type = list(string)
66
+ description = "Command to run"
67
+ }
68
+
69
+ variable "entry_point" {
70
+ type = list(string)
71
+ description = "Container entry point"
72
+ default = ["bash"]
73
+ }
@@ -0,0 +1,15 @@
1
+ data "aws_vpc" "default" {
2
+ filter {
3
+ name = "is-default"
4
+ values = ["true"]
5
+ }
6
+ }
7
+
8
+ # Get all subnets in the default VPC
9
+ data "aws_subnets" "default" {
10
+ filter {
11
+ name = "vpc-id"
12
+ values = [data.aws_vpc.default.id]
13
+ }
14
+ }
15
+
@@ -0,0 +1,41 @@
1
+ resource "aws_security_group" "efs" {
2
+ name = "efs-sg"
3
+ description = "Allow NFS"
4
+
5
+ ingress {
6
+ from_port = 2049
7
+ to_port = 2049
8
+ protocol = "tcp"
9
+ cidr_blocks = ["0.0.0.0/0"]
10
+ }
11
+
12
+ egress {
13
+ from_port = 0
14
+ to_port = 0
15
+ protocol = "-1"
16
+ cidr_blocks = ["0.0.0.0/0"]
17
+ }
18
+
19
+ tags = {
20
+ Name = "efs-sg"
21
+ }
22
+ }
23
+
24
+ resource "aws_security_group" "ssh" {
25
+ name = "allow_ssh"
26
+ description = "Allow SSH inbound traffic"
27
+
28
+ ingress {
29
+ from_port = 22
30
+ to_port = 22
31
+ protocol = "tcp"
32
+ cidr_blocks = ["0.0.0.0/0"] # WARNING: open to the world. Limit this for production.
33
+ }
34
+
35
+ egress {
36
+ from_port = 0
37
+ to_port = 0
38
+ protocol = "-1"
39
+ cidr_blocks = ["0.0.0.0/0"]
40
+ }
41
+ }
@@ -0,0 +1,7 @@
1
+ output "efs_sg_id" {
2
+ value = aws_security_group.efs.id
3
+ }
4
+
5
+ output "ssh_sg_id" {
6
+ value = aws_security_group.ssh.id
7
+ }
File without changes
@@ -0,0 +1,46 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ require 'scout'
5
+ class TestResourceSync < Test::Unit::TestCase
6
+ def test_sync_file
7
+ TmpFile.with_path do |source|
8
+ TmpFile.with_path do |target|
9
+ Open.write(source.file, 'payload')
10
+ Misc.in_dir target.find do
11
+ Resource.sync(source.file, :current)
12
+ end
13
+
14
+ assert_equal 'payload', Open.read(target[Resource.identify(source)].file)
15
+ end
16
+ end
17
+ end
18
+
19
+ def test_sync_dir
20
+ TmpFile.with_path do |source|
21
+ TmpFile.with_path do |target|
22
+ Open.write(source.file, 'payload')
23
+ Misc.in_dir target.find do
24
+ Resource.sync(source, :current)
25
+ end
26
+
27
+ assert_equal 'payload', Open.read(target[Resource.identify(source)].file)
28
+ end
29
+ end
30
+ end
31
+
32
+ def test_sync_from_localhost
33
+ TmpFile.with_path do |source|
34
+ TmpFile.with_path do |target|
35
+ Open.write(source.file, 'payload')
36
+ Misc.in_dir target.find do
37
+ sss 0
38
+ Resource.sync(source, :current, source: 'localhost')
39
+ end
40
+
41
+ assert_equal 'payload', Open.read(target[Resource.identify(source)].file)
42
+ end
43
+ end
44
+ end
45
+ end
46
+
@@ -1,6 +1,7 @@
1
1
  require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
2
  require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
3
 
4
+ require 'scout'
4
5
  class TestSync < Test::Unit::TestCase
5
6
  def test_sync
6
7
  TmpFile.with_path do |tmpdir|
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout-camp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-08 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: scout-essentials
@@ -42,6 +42,7 @@ files:
42
42
  - lib/scout/aws/s3.rb
43
43
  - lib/scout/offsite.rb
44
44
  - lib/scout/offsite/exceptions.rb
45
+ - lib/scout/offsite/resource.rb
45
46
  - lib/scout/offsite/ssh.rb
46
47
  - lib/scout/offsite/step.rb
47
48
  - lib/scout/offsite/sync.rb
@@ -50,12 +51,14 @@ files:
50
51
  - lib/scout/terraform_dsl/util.rb
51
52
  - scout-camp.gemspec
52
53
  - scout_commands/offsite
54
+ - scout_commands/sync
53
55
  - scout_commands/terraform/add/lambda
54
56
  - scout_commands/terraform/add/relay
55
57
  - scout_commands/terraform/apply
56
58
  - scout_commands/terraform/destroy
57
59
  - scout_commands/terraform/lambda_task
58
60
  - scout_commands/terraform/list
61
+ - scout_commands/terraform/outputs
59
62
  - scout_commands/terraform/plan
60
63
  - scout_commands/terraform/remove
61
64
  - scout_commands/terraform/status
@@ -67,12 +70,29 @@ files:
67
70
  - share/terraform/aws/cluster/main.tf
68
71
  - share/terraform/aws/cluster/output.tf
69
72
  - share/terraform/aws/cluster/variables.tf
73
+ - share/terraform/aws/efs/data.tf
74
+ - share/terraform/aws/efs/locals.tf
75
+ - share/terraform/aws/efs/main.tf
76
+ - share/terraform/aws/efs/output.tf
77
+ - share/terraform/aws/efs/variables.tf
78
+ - share/terraform/aws/efs_host/data.tf
79
+ - share/terraform/aws/efs_host/locals.tf
80
+ - share/terraform/aws/efs_host/main.tf
81
+ - share/terraform/aws/efs_host/output.tf
82
+ - share/terraform/aws/efs_host/variables.tf
83
+ - share/terraform/aws/fargate/locals.tf
84
+ - share/terraform/aws/fargate/main.tf
85
+ - share/terraform/aws/fargate/variables.tf
70
86
  - share/terraform/aws/host/locals.tf
71
87
  - share/terraform/aws/host/main.tf
72
88
  - share/terraform/aws/host/output.tf
73
89
  - share/terraform/aws/host/variables.tf
74
90
  - share/terraform/aws/lambda/main.tf
75
91
  - share/terraform/aws/lambda/variables.tf
92
+ - share/terraform/aws/network/data.tf
93
+ - share/terraform/aws/network/main.tf
94
+ - share/terraform/aws/network/output.tf
95
+ - share/terraform/aws/network/variables.tf
76
96
  - share/terraform/aws/policy_attachment/main.tf
77
97
  - share/terraform/aws/policy_attachment/variables.tf
78
98
  - share/terraform/aws/provider/data.tf
@@ -83,6 +103,7 @@ files:
83
103
  - share/terraform/ssh/cmd/main.tf
84
104
  - share/terraform/ssh/cmd/variables.tf
85
105
  - test/scout/aws/test_s3.rb
106
+ - test/scout/offsite/test_resource.rb
86
107
  - test/scout/offsite/test_ssh.rb
87
108
  - test/scout/offsite/test_step.rb
88
109
  - test/scout/offsite/test_sync.rb
@@ -106,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
127
  - !ruby/object:Gem::Version
107
128
  version: '0'
108
129
  requirements: []
109
- rubygems_version: 3.6.5
130
+ rubygems_version: 3.6.7
110
131
  specification_version: 4
111
132
  summary: Deploy you scouts
112
133
  test_files: []