I am at my whits end trying to solve this problem. Our ultimate goal is to deploy a custom docker container of Mautic. I have no problem doing this from their website interface. I've solved all my config problems and it works great. But I need to do this automatically from an API. Customers are going to sign up for our service, and we want to deploy Mautic for them instantly (or as instant as AWS can work).
I'm new to elastic beanstalk and AWS. But what I understand is I need to create an environment and deploy my Dockerrun.aws.json file to it. But I cannot find anywhere in the API that I can specify a file to deploy or even an S3 bucket to use (like you can from the interface). I had hoped by saving a template and using that, it would work, but I just get an empty Docker instance with no container launched.
Here's an example of my PHP api call
$eb = new ElasticBeanstalkClient(array(
'version' => 'latest',
'region' => 'us-east-1',
'credentials' => array(
'key' => '...',
'secret' => '...'
)
));
$newEnvironment = $eb->createEnvironment(array(
'ApplicationName' => 'test',
'TemplateName' => 'foo2',
'EnvironmentName' => '...',
'EnvironmentTier' => array(
'Type' => 'Standard',
'Name' => 'WebServer'
),
'OptionSettings' => array(
[
'Namespace' => 'aws:autoscaling:launchconfiguration',
'OptionName' => 'EC2KeyName',
'Value' => '...'
],
[
'Namespace' => 'aws:rds:dbinstance',
'OptionName' => 'DBUser',
'Value' => '...'
],
[
'Namespace' => 'aws:rds:dbinstance',
'OptionName' => 'DBPassword',
'Value' => '...'
]
)
));
The template foo2 was saved from an environment that has a fully running Mautic docker container.
The problem is, this creates an environment and the RDS resource I need, but does not run my docker container.
Is what I want possible? Or do I have to find another avenue?
Thanks
Figured it out. What I was looking for was $eb->createApplicationVersion(...) which I can use to specify an S3 bucket with my Dockerrun.aws.json file. Documentation
Then I can specify that VersionLabel in my createEnvironment() call like so.
$newEnvironment = $eb->createEnvironment(array(
'ApplicationName' => 'test',
'TemplateName' => 'foo2',
// Right here
'VersionLabel` => 'fooVersion',
'EnvironmentName' => '...',
'EnvironmentTier' => array(
'Type' => 'Standard',
'Name' => 'WebServer'
),
'OptionSettings' => array(
[
'Namespace' => 'aws:autoscaling:launchconfiguration',
'OptionName' => 'EC2KeyName',
'Value' => '...'
],
[
'Namespace' => 'aws:rds:dbinstance',
'OptionName' => 'DBUser',
'Value' => '...'
],
[
'Namespace' => 'aws:rds:dbinstance',
'OptionName' => 'DBPassword',
'Value' => '...'
]
)
));
Or I can just create a version through the Dashboard. Documentation
Related
So I'm using beyondcode/laravel-websockets to setup a WS server and I want to work with multiple apps so I did this in config\websockets.php:
'apps' => [
[
'id' => env('A_APP_ID'),
'name' => env('A_APP_NAME'),
'key' => env('A_APP_KEY'),
'secret' => env('A_APP_SECRET'),
'path' => env('A_APP_PATH'),
'capacity' => null,
'enable_client_messages' => false,
'enable_statistics' => true,
],
[
'id' => env('B_APP_ID'),
'name' => env('B_APP_NAME'),
'key' => env('B_APP_KEY'),
'secret' => env('B_APP_SECRET'),
'path' => env('B_APP_PATH'),
'capacity' => null,
'enable_client_messages' => false,
'enable_statistics' => true,
],
],
However, I want to implement custom handlers for each app and I've been trying this, routes\web.php:
WebSocketsRouter::webSocket('app/{appKey}/bapp', \App\WebSockets\BAppWebSocketHandler::class);
//Also tried this..
WebSocketsRouter::webSocket('app/{appKey}', \App\WebSockets\AAppWebSocketHandler::class);
//and created `AAppWebSocketHandler` which does nothing but calling parent (WebSocketHandler) methods
Problem is it's always using one handler for all apps despite the difference in routes.
Any ideas?
Thanks!
You don't have to define routes while defining multiple apps in the config. Instead configure Echo to work with separate app key and secret. If you want to use custom handler with own logic, then remove them from configs. Also note that, you won't get any channel or pusher client library support. You will have to implement your own authentication as well.
I'm launching an AWS instance using the PHP SDK and everything works well except I'm not able to set the name(tag) of that instance.
Here is my code:
$result_create_instance = $ec2_client->runInstances([
'AdditionalInfo' => 'notihng',
'ImageId' => $aws_ami, // REQUIRED
'MaxCount' => 1, // REQUIRED
'MinCount' => 1, // REQUIRED
'InstanceType' => $aws_instance_type,
'Monitoring' => [
'Enabled' => true // REQUIRED
],
'UserData' => $user_Data,
'SubnetId' => 'subnet-125cxxxx',
'SecurityGroupIds' => ['sg-5axxxxx'],
'TagSpecification` => [
'ResourceType' => 'instance',
'Tags' => [ 'Key' => 'Name',
'Value'=>'my instance'
],
],
]);
Any suggestion will be appreciated.
Thanks
The parameter should be TagSpecifications with an s not TagSpecification. Also make sure you are using a recent version of the AWS SDK since adding tags at launch is a fairly new feature.
Here is my code
$sns = new \Aws\Sns\SnsClient(array(
'credentials' => array(
'key' => 'my_key',
'secret' => 'my_secret'
),
'region' => 'us-west-2',
'version' => 'latest'
));
$msgattributes = [
'AWS.SNS.SMS.SenderID' => [
'DataType' => 'String',
'StringValue' => 'Klassroom',
],
'AWS.SNS.SMS.SMSType' => [
'DataType' => 'String',
'StringValue' => 'Transactional',
]
];
$payload = array(
'Message' => 'this is mine cre',
'PhoneNumber' => '+91**********',
'MessageAttributes' => $msgattributes
);
$result=$sns->publish($payload)->get('MessageId');
Using above code when I run this code I am getting messages to my mobile but I am not getting any response (it is saying 500 internal error). Can any one help me in this please.
My AWS SDK version is 3.33
I solved my problem, problem with SimpleXMLElement. i have installed xml for php 7.o by following command
sudo apt-get install php7.0-xml
And then restart apache or nginx server and it is working fine.
I working with Queue Component for Yii2 from reference https://libraries.io/github/cybercog/yii2-queue
I wants to know that how can i post data into 2-3 different queue url for different feature
for that i have to configure 2-3 user here in below configuration code plsease let me know how can i provide multiple url in configuration
'components' => [
'queue' => [
'class' => 'UrbanIndo\Yii2\Queue\SqsQueue',
'module' => 'task',
'url' => 'https://sqs.ap-southeast-1.amazonaws.com/123456789012/queue',
'config' => [
'key' => 'AKIA1234567890123456',
'secret' => '1234567890123456789012345678901234567890',
'region' => 'ap-southeast-1',
],
]]
or how can i set url while posting data into queue
Yii::$app->queue->post(new Job(['route' => ['sync' => 'emailSync'], 'data' => $options]));
I'm trying to use an external cache engine, memcached, to power my CakePHP app.
I have an AWS EC2 instance running the app and also an AWS ElastiCache Cluster with one node using memcached. The memcache and memcached php modules are also installed and enabled.
The configuration in the app.php file is as follows:
'Cache' => [
'default' => [
'className' => 'File',
'path' => CACHE,
],
'elastic' => [
'className' => 'Cake\Cache\Engine\MemcachedEngine',
'compress' => false,
'duration' => '+2 minutes',
'groups' => [],
'host' => 'yyy.euw1.cache.amazonaws.com:11211',
'username' => null,
'password' => null,
'persistent' => false,
'prefix' => 'cake_',
'probability' => 100,
'serialize' => 'php',
'servers' => ['yyy.euw1.cache.amazonaws.com:11211'],
'options' => [],
'lock' => true
]
To select whether or not to query the database, this condition is used:
if (($car = Cache::read('car', 'elastic')) === false) {
$car = $this->Cars->get();
Cache::write('car', $car, 'elastic');
}
Unfortunately, after a long page load I get this error:
"elastic cache was unable to write to DebugKit\Cache\Engine\DebugEngine cache"
Does anyone knows the origin of this error? Can someone guide me through the configuration of memcached for cakephp, using an external cache engine?
Thank you upfront!
Thank you for your reply.
This issue is now closed. We had to allow IP access between EC2 and CloudCache Cluster.