AWS-CDK : CNAMEPrefix is not getting set in the elasticbeanstalk.CfnEnvironment - amazon-elastic-beanstalk

I am trying to deploy a NodeJS app to elastic beanstalk using AWS CDK, things are working fine, deployment and redeployment works fine.However, the final URL which is generated has random string like 'MyDeployEnv1.eba-5vjzkdss.us-east-1.elasticbeanstalk.com'. While reading through various AWS documentation I came across the property CNAMEPrefix.
So I added the CNAMEPrefix in the elasticbeanstalk.CfnEnvironment call as below :
const elbEnv = new elasticbeanstalk.CfnEnvironment(this, 'Environment', {
environmentName: 'MyDeployEnv1',
CNAMEPrefix: 'myapi14',
applicationName: app.applicationName || appName,
solutionStackName: '64bit Amazon Linux 2018.03 v4.17.0 running Node.js',
optionSettings: optionSettingProperties,
versionLabel: appVersionProps.ref,
});
CNAMEPrefix is not working, any help to change/remove the random alphanumeric string in the URL would be helpful 'MyDeployEnv1.eba-5vjzkdss.us-east-1.elasticbeanstalk.com'
Version details :
aws-cli 2.1.1 Windows/10 exe/AMD64
CDK version : 1.75.0 (build 7708242)

Related

Cannot create node group via sdk

I am trying to create a nodegroup via the aws sdk for node.js I'd prefer to do this than via the eksctl.
This is a simple question but there are just no code examples of this in the aws docs and I can't figure out the correct name spaces so unfortunately I am asking here:
My code is as follows with node.js
const AWS = require('aws-sdk');
AWS.config.update({region: 'us-west-2'});
const eks = new AWS.EKS();
AWS.config.update({region: 'us-west-2'});
// Name must be cluster
eks.CreateNodegroup({name:'openstudio-server',
instanceTypes:["t2.xlarge"],
"nodegroupName":'openstudio-node',
"scalingConfig": {
"desiredSize": 3,
"maxSize": 10,
"minSize": 3
}
})
I am consistently getting the error
What am I doing wrong?
I'm guessing you've resolved this already but it looks like you just need to change eks.CreateNodegroup() to eks.createNodegroup() and it should work.
source: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EKS.html

Quicksight Dashboard Embed url showing us-east-1 not eu-west-1

Problem:
I want to programmatically fetch a quicksight dashboard URL through the SDK, (dashboard in region: eu-west-1) however whenever I use the following regions I get the following errors when I use the following regions:
eu-west-1: Error: Operation is being called from endpoint eu-west-1, but your identity region is us-east-1. Please use the us-east-1 endpoint.
us-east-1: No error, but the embed url is us-east-1 and results in a us-east-1.quicksight.aws.amazon.com refused to connect error in the browser, eg: https://us-east-1.quicksight.aws.amazon.com/embed/XXXXXX&identityprovider=quicksight&isauthcode=true',
Example Code:
Note: Credentials added for brevity, but are loaded from profile. Have also tried in Java SDK.
const AWS = require('aws-sdk')
const dotenv = require('dotenv').config()
const init = async () => {
AWS.config.credentials = {accessKeyId: process.env.ACCESS_KEY_ID, secretAccessKey: process.env.SECRET_ACCESS_KEY}
AWS.config.region = 'us-east-1'
// AWS.config.region = 'eu-west-1'
const quicksight = new AWS.QuickSight()
const embedUrlParams = {
AwsAccountId: '111122223333',
DashboardId: '11111111-2222-3333-4444-555555555555',
IdentityType: 'QUICKSIGHT',
UserArn: 'arn:aws:quicksight:us-east-1:111122223333:user/default/quicksight-user-1111'
}
const embedUrlRes = await quicksight.getDashboardEmbedUrl(embedUrlParams).promise()
console.log('embedUrlRes', embedUrlRes)
}
init()
CLI:
When I envoke exactly the same through CLI, eg:
aws quicksight get-dashboard-embed-url --aws-account-id 111122223333 --dashboard-id 11111111-2222-3333-4444-555555555555 --identity-type QUICKSIGHT --user-arn "arn:aws:quicksight:us-east-1:111122223333:user/default/quicksight-user-1111" --profile my-quicksight-profile
I get the a perfectly valid embed url in eu-west-1 that embeds perfect through the browser:
https://eu-west-1.quicksight.aws.amazon.com/embed/XXXXXXXX&identityprovider=quicksight&isauthcode=true
So:
I imaging that the SDK is not behaving as the CLI is in the respect of assuming roles, but I've tried this with little success, as well as pointing to quicksight regional endpoints.
Before I go down the rabbit hole, it would be good to see if anyone has experienced the same and how they resolved it.
Thanks!
For people who endup here, While generating and embedded link using sdk if your dashboard is in a different region you have to update quicksight parameters of the sdk to that region
something like the following
// Previous code blocks..
quicksight = new AWS.QuickSight({ region: targetRegion })
quicksight.getDashboardEmbedUrl(Params,function (error, embeddedLink){})
Also you have to whitelist domain on each region since quicksight considers each region as seperate entity

How to use aws athena using nodejs?

Athena is analytics service for retrieving data from s3 using sql query.
I have queried data in s3 using t aws console
Need access to aws athena using nodejs code
I am using athena like following way in my nodejs project :
download JDBC driver from AWS.
Create a connector.js file.
npm install jdbc NPM.
Paste followings:
var JDBC = require('jdbc');
var jinst = require('jdbc/lib/jinst');
if (!jinst.isJvmCreated()) {
jinst.addOption("-Xrs");
jinst.setupClasspath(['./AthenaJDBC41-*.jar']);
}
var config = {
// Required
url: 'jdbc:awsathena://athena.*.amazonaws.com:443',
// Optional
drivername: 'com.amazonaws.athena.jdbc.AthenaDriver',
minpoolsize: 10,
maxpoolsize: 100,
properties: {
s3_staging_dir: 's3://aws-athena-query-results-*/',
log_path: '/logs/athenajdbc.log',
user: 'access_key',
password: 'secret_key'
}
};
var hsqldb = new JDBC(config);
hsqldb.initialize(function(err) {
if (err) {
console.log(err);
}
});
Just use the Athena Service on the JS SDK.
Athena JS Documentation
AWS JS SDK
You could use the athena-express module from here, as documented by AWS here
You need to use aws-sdk and athena-express dependencies,
There's a full working tutorial in this video I made:
https://www.youtube.com/watch?v=aBf5Qo9GZ1Yac

Wildcard in Angular http.get?

I have multiple JSON files in one directory, and I am going to build the view contents from those JSON files. The JSON files are identical in structure.
What is the correct syntax for loading multiple JSON files for use with ng-repeat? I tried with this, but it throws a permission denied error (the view is loaded via a route, if it matters. Still learning Angular...).
I use these:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular-route.min.js"></script>
Snippet from the view:
<div ng-controller="releases">
<article ng-repeat="album in albums">
{{ album.artist }}
</article>
</div>
Controller:
myApp.controller('releases', function($scope, $http) {
$scope.albums = [];
$http.get('contents/releases/*.json')
.then(function(releases) {
$scope.albums = releases.data;
console.log($scope.albums);
});
});
The JSON files are like this:
{
"artist" : "Artist name",
"album" : "Album title",
"releaseDate" : "2015-09-16"
}
The error message is:
You don't have permission to access /mypage/angular/contents/releases/*.json on this server.
If I use an exact filename, for example $http.get('contents/releases/album.json'), I can access the data correctly. But naturally only for one JSON, instead of the 11 files I have.
In a previous site I have done with PHP, I used an identical method, and there I could access the same files with no problem. For both, I'm using WAMP server (Apache 2) as the platform.
Could it still have something to do with the Apache config? The reason I don't think it is that, is because it does work in PHP like this:
// Get release data
$releasesDataLocation = 'contents/releases/*.json';
$releasesDataFiles = glob($releasesDataLocation);
rsort($releasesDataFiles); // Rsort = newest release first, comment out to show oldest first
// Show the releases
foreach($releasesDataFiles as $releaseData) {
$release = new Release($releaseData);
$release->display();
}
Wildcard AFAIK in such URLs is not allowed. You should build a server side endpoint that should read all the files in your directory on server, concatenate and return the response to you.
For eX: you could expose a GET URL: /api/contents/releases
and server side handler of it can read the directory containing all release JSONs and return to you.

How can I connect to ArcSDE with GeoTools?

I'm running Oracle ArcSDE 9.2 and using GeoTools 8.5, but doing what they say in the GeoTools docs doesn't seem to work. I have
Map<String, Object> params = new HashMap<String, Object>();
params.put( "dbtype", "arcsde" );
params.put( "server", "164.64.146.42" );
params.put( "port", "5151" );
params.put( "instance", "sde" );
params.put( "user", "sde_admin" );
params.put( "password", "whatever" );
DataStore dataStore;
String typeName;
try
{
dataStore = DataStoreFinder.getDataStore(params);
typeName = dataStore.getTypeNames()[0];
} catch (IOException e)
{
e.printStackTrace();
}
FeatureSource source = dataStore(typeName);
But, after dataStore = dataStoreFinder.getDataStore(params), dataStore is always still null, indicating it didn't connect. I do not get an exception unless I try to use the dataStore object which is null. And I don't expect it to work because it doesn't ask me for a schema. When you connect using GeoServer successfully to the same SDE geodatabase, it insists on a schema parameter, which in my case is "envq.nmenv.state.nm.us." Would I add that onto the server name somewhere? Or what am I missing for this not to connect? I am just trying to connect read-only for now, but eventually I want to put data in using GeoTools.
Using the software uDig, which uses the GeoTools library, has answered my question. When loading from an ArcSDE DataStore via uDig, uDig prompts to know the location of the following jars:
jsde92_sdk.jar
jpe92_sdk.jar
icu4j_3_2.jar
They are not loaded automatically via Maven by adding gt-arcsde to your pom.xml in Eclipse, but are distributed with GeoServer under the ArcSDE Data Store Extension within the filename geoserver-2.2.2-arcsde-plugin.zip
Add their location to your CLASSPATH or in Eclipse go to Project->Properties->Java Build Path and Add External JARs... and choose all three. At that point the above code will work unchanged.