0

Although I have access to my bucket with the profile that I use, (because I can download the file from terminal) when I want to reach it in build.gradle, I'm getting S3 Access Denied error. Interesting thing is, with AWS Toolkit and from the terminal, I can display my bucket with that profile without a problem. My IAM user has AmazonS3FullAccess policy. To make sure, I also added another policy which you can see below. Bucket public access is disabled. (Also I tried with public access but still getting error in gradle build). My goal is to use QA-Base project in the bucket as a dependency in my project. Kindly request your help.

$aws s3 cp s3://maven.egeiper/org/egeiper/qaBase/QA-Base/1.0.7/QA-Base-1.0.7.pom . --profile egeiper

download: s3://maven.egeiper/org/egeiper/qaBase/QA-Base/1.0.7/QA-Base-1.0.7.pom to ./QA-Base-1.0.7.pom

Error in terminal with command "gradle build"
> A problem occurred configuring root project 'QA-Base'.
 Could not resolve all files for configuration ':classpath'.
   Could not resolve org.egeiper.qaBase:QA-Base:1.0.7.
     Required by:
         project :
      Could not resolve org.egeiper.qaBase:QA-Base:1.0.7.
         > Could not get resource 's3://maven.egeiper/org/egeiper/qaBase/QA-Base/1.0.7/QA-Base-1.0.7.pom'.
            > Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: N2RS6X0XMFFQ34XR; S3 Extended Request ID: XqYfJ09KVk7Z/LUmF6kdegaGkPgYXKCy+bukM9NHSWJSYmNrfIh2A/qEmpQLQfh7DuhE2mpl/iJaLxlvPtcjqg==; Proxy: null)

My bucket via AWS Toolkit

My credentials file in .aws/credentials

Config file in .aws/config

[profile egeiper]
region = eu-central-1
output = json

My policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::maven.egeiper"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:DeleteObject"
            ],
            "Resource": [
                "arn:aws:s3:::maven.egeiper/*"
            ]
        }
    ]
}

build.gradle

buildscript {
    repositories {
        mavenCentral()
        maven {
            url "s3://maven.egeiper"
            authentication {
                awsIm(AwsImAuthentication)
            }
        }
    }
    dependencies {
        classpath 'com.github.ksoichiro:gradle-console-reporter:0.6.3'
        classpath 'org.egeiper.qaBase:QA-Base:1.0.7'
    }
}
plugins {
    id 'java'
    id "com.github.spotbugs" version "5.0.13"
    id 'pmd'
    id 'checkstyle'
    id 'maven-publish'
}

group 'org.egeiper.qaBase'
version '1.0.7'
repositories {
    mavenCentral()
    maven {
        url "s3://maven.egeiper"
        authentication {
            awsIm(AwsImAuthentication)
        }
    }
}

java {
    sourceCompatibility JavaVersion.VERSION_11
    targetCompatibility JavaVersion.VERSION_11
}


dependencies {
    implementation 'org.seleniumhq.selenium:selenium-java:4.7.2'
    implementation 'org.testng:testng:7.4.0'
    implementation 'io.qameta.allure:allure-testng:2.19.0'
    implementation 'io.rest-assured:rest-assured:5.3.0'
    implementation 'org.awaitility:awaitility:4.2.0'
    compileOnly 'org.projectlombok:lombok:1.18.24'
    annotationProcessor 'org.projectlombok:lombok:1.18.24'
    implementation 'org.aeonbits.owner:owner:1.0.12'
    implementation 'org.seleniumhq.selenium:selenium-chrome-driver:4.7.2'
    implementation 'org.seleniumhq.selenium:selenium-firefox-driver:4.7.2'
}

pmd {
    consoleOutput = true
    toolVersion = "6.21.0"
    rulesMinimumPriority = 5
    ruleSetConfig = rootProject.resources.text.fromFile("config/pmdRules.xml")
    ruleSets = []
}

checkstyle {
    toolVersion = "8.23"
    configFile = rootProject.file('config/checkstyle.xml')
}

publishing {
    repositories {
        maven {
            url "s3://maven.egeiper"
            authentication {
                awsIm(AwsImAuthentication)
            }
        }
    }
    publications {
        mavenJava(MavenPublication) {
            from components.java
        }
    }

}

test {
    useTestNG()
    maxParallelForks = Runtime.runtime.availableProcessors()
}
Chris F
  • 14,337
  • 30
  • 94
  • 192
Ege İper
  • 1
  • 3

0 Answers0