Method: AwsIamPasswordPolicy#initialize

Defined in:
lib/resources/aws/aws_iam_password_policy.rb

#initialize(conn = nil) ⇒ AwsIamPasswordPolicy

TODO: rewrite to avoid direct injection, match other resources, use AwsSingularResourceMixin



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/resources/aws/aws_iam_password_policy.rb', line 18

def initialize(conn = nil)
  catch_aws_errors do
    begin
      if conn
        # We're in a mocked unit test.
        @policy = conn.iam_resource.
      else
        # Don't use the resource approach.  It's a CRUD operation
        # - if the policy does not exist, you get back a blank object to  populate and save.
        # Using the Client will throw an exception if no policy exists.
        @policy = inspec_runner.backend.aws_client(Aws::IAM::Client)..password_policy
      end
    rescue Aws::IAM::Errors::NoSuchEntity
      @policy = nil
    end
  end
end