private[policy] def hierarchyPath()

in configTools/src/main/scala/com/gu/janus/policy/Statements.scala [18:43]


  private[policy] def hierarchyPath(path: String) =
    s"${path.stripSuffix("/")}/*"

  /** Grants read-only access to a given path in an s3 bucket.
    *
    * Provided path should include leading slash and omit trailing slash.
    */
  def s3ReadAccess(
      bucketName: String,
      path: String,
      effect: Effect = Effect.Allow
  ): Seq[Statement] = {
    assert(
      enforceCorrectPath(path),
      s"Provided path should include leading slash and omit trailing slash ($bucketName :: $path)"
    )
    s3ConsoleEssentials(bucketName) :+
      Statement(
        effect,
        Seq(Action("s3:Get*"), Action("s3:List*")),
        Seq(
          Resource(s"arn:aws:s3:::$bucketName$path"),
          Resource(s"arn:aws:s3:::$bucketName${hierarchyPath(path)}")
        )
      )
  }