Class: AwsAccountNumber::CLI
- Inherits:
-
Thor
- Object
- Thor
- AwsAccountNumber::CLI
- Includes:
- Thor::Aws
- Defined in:
- lib/aws_account_number/cli.rb
Instance Method Summary collapse
Instance Method Details
#cfn ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/aws_account_number/cli.rb', line 23 def cfn template = <<-EOT { "Resources":{ "WaitHandle":{ "Type":"AWS::CloudFormation::WaitConditionHandle" }, "Wait":{ "Type":"AWS::CloudFormation::WaitCondition", "Properties":{ "Handle":{ "Ref":"WaitHandle" }, "Timeout":"1" } } } } EOT begin result = cloudformation.client.create_stack( stack_name: "accountnumber#{Time.now.to_i}", template_body: template, on_failure: "DELETE" ) puts result.stack_id.split(':')[4] rescue RuntimeError => e $stderr.puts e exit 1 end end |
#iamuser ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/aws_account_number/cli.rb', line 54 def iamuser begin puts iam.current_user.arn.split(':')[4] rescue RuntimeError => e $stderr.puts e exit 1 end end |
#security_group ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/aws_account_number/cli.rb', line 13 def security_group begin puts ec2.client.describe_security_groups(group_names: ['default']).security_groups.first.owner_id rescue RuntimeError => e $stderr.puts e exit 1 end end |
#simpletoken ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/aws_account_number/cli.rb', line 64 def simpletoken begin puts sts.client.get_caller_identity.account rescue RuntimeError => e $stderr.puts e exit 1 end end |