scout-camp 0.1.3 → 0.1.4

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: 91e19b9f83e8b15a04642fa32d87a0af095b382a9698c169c454edffda2cdc1f
4
- data.tar.gz: 92f2e5d29ed614db92ed7bfe3cdb25a55f2d64b2c8ab91bc12dda8939dfb76db
3
+ metadata.gz: bc2855face5f3cb3ced365171398295b656f378fc681da6f0cd530c2c2977ea6
4
+ data.tar.gz: baacce8525b32344f5391d9fa61b62dbb639a91bbddb2ca392a8f7ac8ce762f3
5
5
  SHA512:
6
- metadata.gz: 4dab11e3e250669b167f0f8f49e16fba9b8b55b66a4b6254f1815d4e04282e257442e25e72368616a33ac9a2bfcf471b32466d01833de94328cd2138ad7522c3
7
- data.tar.gz: f3c21f33ee76f8fc8a90d231e46a620262647eac1941d34adf3aba3fc4100d2f77d3b390a339ed43e379cb95fd3378fd7d25df891e9f4799221f4f97aac75995
6
+ metadata.gz: c4e5de039eaba61b854f1b0af3a41172d95bbd872f64750d8bd9775b6321bcc0cbe174adbdf684a14ff836195b6cc840be06d97ddd4803ceb2b56cb032302d91
7
+ data.tar.gz: ca4e6b9e69160ba22e57b3b2cadc9a669f628fdf47b20ea696cf2678b998f686bb6eebc6abcc9aba03369356a5257175b701f080dafd9bb464b3f71cbcceb779
data/.vimproject CHANGED
@@ -29,6 +29,7 @@ scout-camp=/$PWD filter="*" {
29
29
  add
30
30
  status
31
31
  apply
32
+ plan
32
33
  destroy
33
34
  remove
34
35
  }
@@ -41,19 +42,28 @@ scout-camp=/$PWD filter="*" {
41
42
  output.tf
42
43
  variables.tf
43
44
  }
44
- cluster=cluster {
45
+ lambda=lambda {
46
+ main.tf
47
+ variables.tf
48
+ }
49
+ role=role{
45
50
  main.tf
51
+ variables.tf
46
52
  output.tf
53
+ }
54
+ policy_attachment=policy_attachment {
55
+ main.tf
47
56
  variables.tf
48
57
  }
49
- host=host {
50
- locals.tf
58
+ cluster=cluster {
51
59
  main.tf
52
60
  output.tf
53
61
  variables.tf
54
62
  }
55
- lambda=lambda {
63
+ host=host {
64
+ locals.tf
56
65
  main.tf
66
+ output.tf
57
67
  variables.tf
58
68
  }
59
69
  provider=provider {
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
data/lib/scout/aws/s3.rb CHANGED
@@ -18,10 +18,15 @@ module Open
18
18
  end
19
19
 
20
20
  def self.claim(uri, ...)
21
- is_s3? uri
21
+ if Path === uri and not uri.located?
22
+ is_s3? uri.find
23
+ else
24
+ is_s3? uri
25
+ end
22
26
  end
23
27
 
24
28
  def self.parse_s3_uri(uri)
29
+ uri = uri.find if Path === uri and not uri.located?
25
30
  uri = uri.sub(%r{^s3://}, '')
26
31
  bucket, *key_parts = uri.split('/', -1)
27
32
  key = key_parts.join('/').sub(%r{^/}, '')
data/scout-camp.gemspec CHANGED
@@ -2,11 +2,11 @@
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.3 ruby lib
5
+ # stub: scout-camp 0.1.4 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "scout-camp".freeze
9
- s.version = "0.1.3".freeze
9
+ s.version = "0.1.4".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]
@@ -42,6 +42,7 @@ Gem::Specification.new do |s|
42
42
  "scout_commands/terraform/apply",
43
43
  "scout_commands/terraform/destroy",
44
44
  "scout_commands/terraform/list",
45
+ "scout_commands/terraform/plan",
45
46
  "scout_commands/terraform/remove",
46
47
  "scout_commands/terraform/status",
47
48
  "share/terraform/aws/bucket/main.tf",
@@ -56,8 +57,13 @@ Gem::Specification.new do |s|
56
57
  "share/terraform/aws/host/variables.tf",
57
58
  "share/terraform/aws/lambda/main.tf",
58
59
  "share/terraform/aws/lambda/variables.tf",
60
+ "share/terraform/aws/policy_attachment/main.tf",
61
+ "share/terraform/aws/policy_attachment/variables.tf",
59
62
  "share/terraform/aws/provider/data.tf",
60
63
  "share/terraform/aws/provider/output.tf",
64
+ "share/terraform/aws/role/main.tf",
65
+ "share/terraform/aws/role/output.tf",
66
+ "share/terraform/aws/role/variables.tf",
61
67
  "test/scout/aws/test_s3.rb",
62
68
  "test/scout/offsite/test_ssh.rb",
63
69
  "test/scout/offsite/test_step.rb",
@@ -82,11 +82,22 @@ lambda_package dependencies, workflows, code do |file|
82
82
  filename = 'lambda_package.zip'
83
83
  Open.cp file, dir[filename]
84
84
 
85
- terraform.add :aws, :lambda, function_name: "#{name}Job", filename: filename,
85
+ role = terraform.add :aws, :role, role_name: "lambda_execution_role", principal: {Service: ["lambda.amazonaws.com"]}
86
+
87
+ terraform.add :aws, :policy_attachment, name: "exec_policy", policy_name: "lamda_basic_execution",
88
+ roles: [role.id],
89
+ policy_arn: "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
90
+
91
+ terraform.add :aws, :policy_attachment, name: "s3_policy", policy_name: "lamda_s3_full_access",
92
+ roles: [role.id],
93
+ policy_arn: "arn:aws:iam::aws:policy/AmazonS3FullAccess"
94
+
95
+ terraform.add :aws, :lambda, function_name: "#{name}Job", filename: filename, role: role.arn,
86
96
  environment_variables: {
87
97
  HOME: '.',
88
98
  HOSTNAME: "aws_lambda",
89
99
  AWS_BUCKET: options[:bucket],
100
+ SCOUT_NOCOLOR: "true"
90
101
  }
91
102
 
92
103
  terraform.config dir
@@ -0,0 +1,31 @@
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.plan
31
+
@@ -1,40 +1,13 @@
1
- provider "aws" {
2
- region = "eu-west-2"
3
- }
4
-
5
1
  resource "aws_lambda_function" "this" {
6
2
  function_name = var.function_name
7
- role = aws_iam_role.lambda_role.arn
8
3
  handler = "lambda_function.lambda_handler"
9
4
  runtime = var.runtime
10
5
  filename = var.filename
11
6
  source_code_hash = filebase64sha256(var.filename)
12
7
  timeout = var.timeout
8
+ role = var.role
13
9
 
14
10
  environment {
15
11
  variables = var.environment_variables
16
12
  }
17
13
  }
18
-
19
- resource "aws_iam_role" "lambda_role" {
20
- name = "lambda_execution_role"
21
-
22
- assume_role_policy = jsonencode({
23
- Version = "2012-10-17"
24
- Statement = [
25
- {
26
- Action = "sts:AssumeRole"
27
- Effect = "Allow"
28
- Principal = {
29
- Service = "lambda.amazonaws.com"
30
- }
31
- }
32
- ]
33
- })
34
- }
35
-
36
- resource "aws_iam_policy_attachment" "lambda_basic" {
37
- name = "lambda_basic"
38
- roles = [aws_iam_role.lambda_role.name]
39
- policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
40
- }
@@ -21,3 +21,7 @@ variable "environment_variables" {
21
21
  description = "A map of environment variables to pass to the resource"
22
22
  default = {}
23
23
  }
24
+ variable "role" {
25
+ description = "Role to assume"
26
+ type = string
27
+ }
@@ -0,0 +1,5 @@
1
+ resource "aws_iam_policy_attachment" "this" {
2
+ name = var.policy_name
3
+ roles = var.roles
4
+ policy_arn = var.policy_arn
5
+ }
@@ -0,0 +1,12 @@
1
+ variable "policy_arn" {
2
+ description = "Policy arn"
3
+ type = string
4
+ }
5
+ variable "policy_name" {
6
+ description = "Policy name"
7
+ type = string
8
+ }
9
+ variable "roles" {
10
+ description = "Roles to which to attach policy"
11
+ type = set(string)
12
+ }
@@ -0,0 +1,14 @@
1
+ resource "aws_iam_role" "this" {
2
+ name = var.role_name
3
+
4
+ assume_role_policy = jsonencode({
5
+ Version = "2012-10-17"
6
+ Statement = [
7
+ {
8
+ Action = "sts:AssumeRole"
9
+ Effect = "Allow"
10
+ Principal = var.principal
11
+ }
12
+ ]
13
+ })
14
+ }
@@ -0,0 +1,15 @@
1
+ output "arn" {
2
+ description = "Role arn"
3
+ value = aws_iam_role.this.arn
4
+ }
5
+
6
+ output "name" {
7
+ description = "Role name"
8
+ value = aws_iam_role.this.name
9
+ }
10
+
11
+ output "id" {
12
+ description = "Role id"
13
+ value = aws_iam_role.this.id
14
+ }
15
+
@@ -0,0 +1,11 @@
1
+ variable "role_name" {
2
+ description = "Role name"
3
+ type = string
4
+ }
5
+
6
+ variable "principal" {
7
+ description = "Principal that can assume the role"
8
+ type = map(any)
9
+ }
10
+
11
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout-camp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
@@ -54,6 +54,7 @@ files:
54
54
  - scout_commands/terraform/apply
55
55
  - scout_commands/terraform/destroy
56
56
  - scout_commands/terraform/list
57
+ - scout_commands/terraform/plan
57
58
  - scout_commands/terraform/remove
58
59
  - scout_commands/terraform/status
59
60
  - share/terraform/aws/bucket/main.tf
@@ -68,8 +69,13 @@ files:
68
69
  - share/terraform/aws/host/variables.tf
69
70
  - share/terraform/aws/lambda/main.tf
70
71
  - share/terraform/aws/lambda/variables.tf
72
+ - share/terraform/aws/policy_attachment/main.tf
73
+ - share/terraform/aws/policy_attachment/variables.tf
71
74
  - share/terraform/aws/provider/data.tf
72
75
  - share/terraform/aws/provider/output.tf
76
+ - share/terraform/aws/role/main.tf
77
+ - share/terraform/aws/role/output.tf
78
+ - share/terraform/aws/role/variables.tf
73
79
  - test/scout/aws/test_s3.rb
74
80
  - test/scout/offsite/test_ssh.rb
75
81
  - test/scout/offsite/test_step.rb