Giter Club home page Giter Club logo

Comments (6)

jonapich avatar jonapich commented on May 30, 2024 1

@leptitchriss I only use it once in a while in limited sessions, never had them expire.

malade ton nickname 😆

from aws-es-proxy.

jamesrenaud avatar jamesrenaud commented on May 30, 2024

Check out #1

from aws-es-proxy.

jonapich avatar jonapich commented on May 30, 2024

I wasn't able to make it work OOTB either. It probably supports simple profiles, but it doesn't seem to support Assume Roles embedded into profiles. You gotta do the assume role yourself and then output the environment variables for aws-es-proxy to use.

Here's the script I used, hope it can be useful to someone else:

import boto3
from subprocess import run, PIPE

sts = boto3.Session(profile_name='profile_name').client('sts')
creds = sts.assume_role(RoleSessionName='anything_goes',
                        RoleArn='arn:aws:iam::ACCOUNTID:role/ROLE_TO_ASSUME',
                        DurationSeconds=4*60*60)['Credentials']

proxy_args = ['./aws-es-proxy',
              '-endpoint', 'https://my-aws-es-cluster.region.es.amazonaws.com',
              '-verbose',
              '-pretty']

proxy_enviroment = {
    'AWS_ACCESS_KEY_ID': creds['AccessKeyId'],
    'AWS_SECRET_ACCESS_KEY': creds['SecretAccessKey'],
    'AWS_SESSION_TOKEN': creds['SessionToken']
}

proxy = run(proxy_args, env=proxy_enviroment, stdout=PIPE)

from aws-es-proxy.

abutaha avatar abutaha commented on May 30, 2024

Hi,

The ask for a '-profile' option has been raised multiple times. I see that most of the requests come when assume role is being used. I will work on this in the coming days and find a way to better support assuming roles and using different profiles.

Thanks,

from aws-es-proxy.

Issif avatar Issif commented on May 30, 2024

If it can help, here a snippet from one of my tool for AWS :

	// Arguments
	region := flag.String("region", "eu-west-1", "AWS region")
	profile := flag.String("profile", "default", "Profile from ~/.aws/config")
	flag.Parse()

	// Create session (credentials from ~/.aws/config)
	sess := session.Must(session.NewSessionWithOptions(session.Options{
		SharedConfigState:       session.SharedConfigEnable,  //enable use of ~/.aws/config
		AssumeRoleTokenProvider: stscreds.StdinTokenProvider, //ask for MFA if needed
		Profile:                 string(*profile),
		Config:                  aws.Config{Region: aws.String(*region)},
	}))

Regards,

from aws-es-proxy.

leptitchriss avatar leptitchriss commented on May 30, 2024

I wasn't able to make it work OOTB either. It probably supports simple profiles, but it doesn't seem to support Assume Roles embedded into profiles. You gotta do the assume role yourself and then output the environment variables for aws-es-proxy to use.

Here's the script I used, hope it can be useful to someone else:

import boto3
from subprocess import run, PIPE

sts = boto3.Session(profile_name='profile_name').client('sts')
creds = sts.assume_role(RoleSessionName='anything_goes',
                        RoleArn='arn:aws:iam::ACCOUNTID:role/ROLE_TO_ASSUME',
                        DurationSeconds=4*60*60)['Credentials']

proxy_args = ['./aws-es-proxy',
              '-endpoint', 'https://my-aws-es-cluster.region.es.amazonaws.com',
              '-verbose',
              '-pretty']

proxy_enviroment = {
    'AWS_ACCESS_KEY_ID': creds['AccessKeyId'],
    'AWS_SECRET_ACCESS_KEY': creds['SecretAccessKey'],
    'AWS_SESSION_TOKEN': creds['SessionToken']
}

proxy = run(proxy_args, env=proxy_enviroment, stdout=PIPE)

@jonapich I know your post is over a year old and the project has been updated since, but I'm running into a very similar problem as you dealing with Assumed Roles and have implemented a very similar solution. What happens to your process once the session token expires? I'm considering going with this approach and simply refreshing the session credentials and restarting the proxy each time but it does not seem as elegant as I would have liked.

@abutaha on a side note, the proxy credentials don't seem to pick up the AWS_SESSION_TOKEN in the ~/.aws/credentials file for the default profile. Is that something that can be added? This way we would be able to simply update the temporary credentials provided by the Assume Role call (via aws cli, boto3, or other) and the proxy would simply update itself with the new credentials without having to worry about updating environment variables for a running process.

Aside from that, thank you for your hard work, this project solves a very niche problem that I'm surprised AWS hasn't tackled themselves...

Let me know what you think!

from aws-es-proxy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.