Sha256: 73680b282e9ff6d206731676b5368fdec2c05d89fcf2f2d9d844bf095802b2bd

Contents?: true

Size: 907 Bytes

Versions: 10

Compression:

Stored size: 907 Bytes

Contents

module TerraspacePluginAws::Interfaces::Helper
  class Secret < SecretBase
    def fetch(secret_id)
      secret_id = expansion(secret_id) if expand?
      value = fetch_value(secret_id)
      value = Base64.strict_encode64(value).strip if @base64
      value
    end

    def fetch_value(secret_id)
      secret_value = secretsmanager.get_secret_value(secret_id: secret_id)
      secret_value.secret_string
    rescue Aws::SecretsManager::Errors::ResourceNotFoundException => e
      logger.info "WARN: secret_id #{secret_id} not found".color(:yellow)
      logger.info e.message
      "NOT FOUND #{secret_id}" # simple string so Kubernetes YAML is valid
    rescue Aws::SecretsManager::Errors::ValidationException => e
      logger.info "WARN: secret_id #{secret_id} not found".color(:yellow)
      logger.info e.message
      "INVALID NAME #{secret_id}" # simple string so tfvars valid
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
terraspace_plugin_aws-0.6.1 lib/terraspace_plugin_aws/interfaces/helper/secret.rb
terraspace_plugin_aws-0.6.0 lib/terraspace_plugin_aws/interfaces/helper/secret.rb
terraspace_plugin_aws-0.5.1 lib/terraspace_plugin_aws/interfaces/helper/secret.rb
terraspace_plugin_aws-0.5.0 lib/terraspace_plugin_aws/interfaces/helper/secret.rb
terraspace_plugin_aws-0.4.2 lib/terraspace_plugin_aws/interfaces/helper/secret.rb
terraspace_plugin_aws-0.4.1 lib/terraspace_plugin_aws/interfaces/helper/secret.rb
terraspace_plugin_aws-0.4.0 lib/terraspace_plugin_aws/interfaces/helper/secret.rb
terraspace_plugin_aws-0.3.8 lib/terraspace_plugin_aws/interfaces/helper/secret.rb
terraspace_plugin_aws-0.3.7 lib/terraspace_plugin_aws/interfaces/helper/secret.rb
terraspace_plugin_aws-0.3.6 lib/terraspace_plugin_aws/interfaces/helper/secret.rb