Using the AWS dashboard, and under Security Groups, I see them listed under the following columns:
Name......Security Group ID.....Security Group Name.....VPC ID. Description.....Owner......
The AWS PHP SDK v 3.xx has a createSecurityGroup method under the Ec2Client, that allows the creation of security group. I am using it, but I can't figure out how to set the "name" value (first column). The docs do not describe how to do this.
I tried adding a Name parameter (to mimic the CLI), but it did not work.
$Ec2Client = new Aws\Ec2\Ec2Client([
'version' => 'latest',
'region' => 'us-east-1,
'profile' => 'default']);
$SecGroupParams = ['Name' => 'My Security Group','Description' => 'My Security Group', 'GroupName' => 'my_security_group', 'VpcId' => 'vpc-xxxxxx']
Ec2Client->createSecurityGroup($SecGroupParams);
The group is create, but the name is empty (just like when it's created using the dashboard).
Any idea how to do this?
Picture of dashboard:
What you are trying to do with 'Name' => 'My Security Group' will not work, as the Name should be a Tag with key called "Name". So you have to tag your security group. This is done using CreateTags in PHP.
you should mention the Name in tags.
$SecGroupParams = ['Name' => 'My Security Group','Description' => 'My Security Group', 'GroupName' => 'my_security_group', 'VpcId' => 'vpc-xxxxxx', 'Tags' => [['Key' => 'Name', 'Value' => 'My Security Group']]]
Related
I am trying to send some text to AWS Polly to convert to speech and then save that mp3 file to S3. That part seems to work now.
// Send text to AWS Polly
$client_polly = new Aws\Polly\PollyClient([
'region' => 'us-west-2',
'version' => 'latest',
'credentials' => [
'key' => $aws_useKey,
'secret' => $aws_secret,
]
]);
$text = 'Test. Test. This is a sample text to be synthesized.';
$voice = 'Matthew';
$result_polly = $client_polly->startSpeechSynthesisTask([
'Text' => $text,
'TextType' => 'text',
'OutputFormat' => 'mp3',
'OutputS3BucketName' => $aws_bucket,
'OutputS3KeyPrefix' => 'files/audio/,
'VoiceId' => $voice,
'ACL' => 'public-read'
]);
echo $result_polly['ObjectURL'];
I'm also trying to accomplish couple other things:
Make mp3 file publicly accessible. Currently I have to go to AWS console to
click "Make Public" button. It seems that 'ACL' => 'public-read' doesn't work for me
I need to return full URL of the mp3 file. For some reason $result_polly['ObjectURL']; doesn't get any value.
What am I missing?
There is no ACL field in the StartSpeechSynthesisTask call:
$result = $client->startSpeechSynthesisTask([
'LanguageCode' => 'arb|cmn-CN|cy-GB|da-DK|de-DE|en-AU|en-GB|en-GB-WLS|en-IN|en-US|es-ES|es-MX|es-US|fr-CA|fr-FR|is-IS|it-IT|ja-JP|hi-IN|ko-KR|nb-NO|nl-NL|pl-PL|pt-BR|pt-PT|ro-RO|ru-RU|sv-SE|tr-TR',
'LexiconNames' => ['<string>', ...],
'OutputFormat' => 'json|mp3|ogg_vorbis|pcm', // REQUIRED
'OutputS3BucketName' => '<string>', // REQUIRED
'OutputS3KeyPrefix' => '<string>',
'SampleRate' => '<string>',
'SnsTopicArn' => '<string>',
'SpeechMarkTypes' => ['<string>', ...],
'Text' => '<string>', // REQUIRED
'TextType' => 'ssml|text',
'VoiceId' => 'Aditi|Amy|Astrid|Bianca|Brian|Carla|Carmen|Celine|Chantal|Conchita|Cristiano|Dora|Emma|Enrique|Ewa|Filiz|Geraint|Giorgio|Gwyneth|Hans|Ines|Ivy|Jacek|Jan|Joanna|Joey|Justin|Karl|Kendra|Kimberly|Lea|Liv|Lotte|Lucia|Mads|Maja|Marlene|Mathieu|Matthew|Maxim|Mia|Miguel|Mizuki|Naja|Nicole|Penelope|Raveena|Ricardo|Ruben|Russell|Salli|Seoyeon|Takumi|Tatyana|Vicki|Vitoria|Zeina|Zhiyu', // REQUIRED
]);
Therefore, you will either need to make another call to Amazon S3 to change the ACL of the object, or use an Amazon S3 Bucket Policy to make the bucket (or a path within the bucket) public.
The output location is given in the OutputUri field (NOT OutputUrl -- URI vs URL).
I want to create presigned S3 URL as mentioned here:
https://docs.aws.amazon.com/aws-sdk-php/v3/guide/service/s3-presigned-url.html
My code is quite similar to the example mentioned in the url:
$sdk = new Aws\Sdk( [
'region' => 'eu-west-2',
'version' => 'latest',
] );
$s3Client = $sdk->createS3();
$cmd = $s3Client->getCommand('GetObject', [
'Bucket' => 'books.com',
'Key' => 'testKey'
]);
$request = $s3Client->createPresignedRequest($cmd, '+20 minutes');
// Get the actual presigned-url
$presignedUrl = (string) $request->getUri();
The above generates urls like so:
https://s3.eu-west-2.amazonaws.com/books.com/testKey?X-Amz-Content-Sha256=....
This is as expected. However my S3 bucket has Static Website Hosting and I use a CNAME record allowing me to use a different base url.
Therefore I want the following URL instead:
http://books.com/my-bucket/testKey?X-Amz-Content-Sha256=....
How can I do this?
You can set the endpoint to your bucket domain name:
$sdk = new Aws\Sdk( [
'region' => 'eu-west-2',
'version' => 'latest',
'endpoint' => 'http://books.com',
'bucket_endpoint' => true
] );
This will generate a signed URL that looks like this:
http://books.com/testKey?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAI2V4Lxxxxxxxxxxx%2F20171116%2Feu-west-2%2Fs3%2Faws4_request&X-Amz-Date=20171116T191003Z&X-Amz-SignedHeaders=host&X-Amz-Expires=1200&X-Amz-Signature=0b735cb661b1d2e25c7f5b477d4c657f160a85aa53bee3ea91244340f6d37dee
I have deployed a Yii2 based app onto AWS Elastic Beanstalk, also I have created the RDS instance with a database (it already has tables) on Elastic Beanstalk. However I received this error: "SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known"
All the files are uploaded correctly to the AWS instance.
The file /common/config/main-local.php has:
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=',
'dsn' => 'mysql:host=RDS_HOSTNAME:RDS_PORT;dbname=RDS_DB_NAME',
'username' => 'RDS_USERNAME',
'password' => 'RDS_PASSWORD',
'charset' => 'utf8',
],
What could be wrong? Thanks.
I am guessing that you want pass db information through environment variables. You may want to try to revise the code as below.
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=',
'dsn' => 'mysql:host='.$_SERVER['RDS_HOSTNAME'].':'.$_SERVER['RDS_PORT'].';dbname='.$_SERVER['RDS_DB_NAME'],
'username' => $_SERVER['RDS_USERNAME'],
'password' => $_SERVER['RDS_PASSWORD'],
'charset' => 'utf8',
],
You can reference http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.RDS.html#rds-external-ec2classic in To configure environment properties section to configure your environment variables. Hope this works.
You have 2 times your 'dsn' line and maybe the first one survives, so changing your config to this should work:
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=RDS_HOSTNAME:RDS_PORT;dbname=RDS_DB_NAME',
'username' => 'RDS_USERNAME',
'password' => 'RDS_PASSWORD',
'charset' => 'utf8',
],
(In addition I hope you are aware that you have to change RDS_* parameters :D)
I want create ticket in OTRS system from my own web service and for this goal I use OTRS API (OTRS API - merthod "Ticked created"). Work fine, but I want send email to a specific users.
This my current options for request:
$options = [
"Ticket" => [
"Title" => "Title",
"Queue" => "PT",
"State" => "open",
"Type" => 'Unclassified',
"Priority" => "3 normal",
"Owner" => 'admin#gmail.ru',
// I think this options set getter email, but NO
'CustomerUser' => 'specific_user#gmail.com',
],
"Article" => [
"SenderType" => 'agent',
"ArticleType" => "email-external",
"Subject" => "Subject Article",
"Body" => "Body Article",
"ContentType" => "text/plain; charset=utf8",
"From" => 'admin#gmail.ru' // from whom message
]
];
This screen after created ticked
OTRS ticket created
Any idea what I can change in my $options.
If you create a ticket via the API, by default this will NOT trigger sending an email to the customer, not even if you set the article type as 'email-external'.
If you do want this to happen, the best way is to create a new Notification (prior to OTRS 5 this would be an 'Event Based Notification') as described here: http://otrs.github.io/doc/manual/admin/stable/en/html/administration.html#adminarea-ticket-notifications
You can match on the TicketCreate event, the user who created the ticket via the Web Service, and maybe other attributes as well.
I have my Laravel 4 project up on my EC2 server in AWS, and the final step is to connect my db and memcache.
My question is what host, port and weight do I use for memcache in Laravel. I assume that the "host" is just the public DNS key: ec2-**-***-***-***.**-****-*.compute.amazonaws.com. But what do I use for the port and weight?
'memcached' => array(
array('host' => 'ec2-**-***-***-***.**-****-*.compute.amazonaws.com', 'port' => ?, 'weight' => ?),
),
but I am not sure what to use for port and weight. Is the port just 3306?
Also, for the mysql db. I was able to connect with my db using sql pro by ssh host. And I created a new db there "cs". What credentials would I use for this? Would it look like the below?:
'mysql' => array(
'driver' => 'mysql',
'host' => 'ec2-**-***-***-***.**-****-*.compute.amazonaws.com',
'database' => 'cs',
'username' => '****',
'password' => '************',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
'default' => array(
'host' => 'ec2-**-***-***-***.**-****-*.compute.amazonaws.com',
'port' => ?,
'database' => 0,
),
Again, what port to use?
Finally, how do I update the MySQL username and password on my server so they are not just root. Thank you for all of your help!
Unless your database and/or Memcached are on a separate instance, you should use localhost as the hostname for both.
The MySQL port should be 3306 by default unless you manually changed it in your MySQL configuration.
The Memcache port should be 11211 by default and weight should be 100 (default) and doesn't matter unless you use multiple cache servers.