Closed tompierce closed 10 years ago
Not quite sure why that wouldn't work. The way it's set now if there is no public DNS, it should fallback on the private
Would it be better if I made it configureable?? And do something like ..
if("true".equals(AppConfig.getProperty("usePublicDNS")) {
if (StringUtils.isNotEmpty(instance.getPublicDnsName())) {
hostSystem.setHost(instance.getPublicDnsName());
} else {
hostSystem.setHost(instance.getPublicIpAddress());
}
} else {
if (StringUtils.isNotEmpty(instance.getPrivateDnsName())) {
hostSystem.setHost(instance.getPrivateDnsName());
} else {
hostSystem.setHost(instance.getPrivateIpAddress());
}
}
Ah, sorry. I should have explained better.
We can hit the web app no problem. But when I try to add my AWS credentials I get an "Invalid Credentials" error, which I assume is caused by EC2Box not being able to reach Amazon.
I believe you can supply proxy settings when you create an EC2Client. eg. in AWSCredAction.java
BasicAWSCredentials awsCredentials = new BasicAWSCredentials(awsCred.getAccessKey(), awsCred.getSecretKey());
AmazonEC2 service = new AmazonEC2Client(awsCredentials);
You can use the AmazonEC2Client constructor which also takes an AWSClientConfiguration.
I guess there might be other places where this configuration is necessary?
Gotcha! It's only in 2 or 3 places, so it should be easy. I'll just have a place for the proxy settings in the config file https://github.com/skavanagh/EC2Box/blob/master/src/main/resources/EC2BoxConfig.properties
I noticed a typo in AWSClientConfig.java
if (StringUtils.isNotEmpty(awsProxyPort)) {
config.setProxyHost(awsProxyPort);
}
should be
if (StringUtils.isNotEmpty(awsProxyPort)) {
config.setProxyPort(Integer.parseInt(awsProxyPort));
}
(or similar)
With that change I'm able to set my AWS creds and my EC2 keys. However I get an error when I try to create an ssh terminal. The first time I tried I got an error box with "Unknown Host Exception". But subsequently I just get to the "No sessions could be created" page and lots of JdbcSQLException in the logs. eg.
org.h2.jdbc.JdbcSQLException: NULL not allowed for column "HOST"; SQL statement:
insert into system (display_nm, user, host, port, instance_id, key_id, region, state, instance_status, system_status) values (?,?,?,?,?,?,?,?,?,?) [23502-175]
I can fork and try and get a pull request together in the next few days if you'd like? I suspect that the SSHUtil stuff will also need to know about the proxy settings.
Whoops! Thanks!
Sounds like it's not getting anything back for the host info.
It should be right here...
Not sure what else to use.
try https://github.com/skavanagh/EC2Box/commit/2e849e9e06f08f646badbca6968555b30bc6f78f
I guess if it's in a VPC you have to get the private DNS from getNetworkInterfaces()
I've realised I'm thinking about this wrong. I can sidestep the problem of deploying to our local network (which is behind a proxy server) by just deploying to an EC2 instance. I'll hopefully have some time to do it tomorrow. There might be some more work to do to support VPC's but I don't have much experience with those.
Thanks for all your help! I'll close this now.
No problem. I guess I was thinking you had already deployed it to your local network. Anyway you have it setup you need a value back for host, it won't work if it's null. I don't have any experience with VPC's either. And I'm not really sure the rules of when to set it to public DNS, private DNS or the private DNS off of the getNetworkInterfaces() method ..but it should be in that block of code somewhere, just needs a value for host. Thanks for making me think about it!
It would be great if we could use this from behind our corporate proxy. Any plans to include this?