Yii2 UrlManager route a file name - regex

I have the following rule in my UrlManager:
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'cache' => null,
'rules' => [
'classic_articles/<route:.*>' => 'site/classic-articles',
// your rules go here
]
],
However it is not going to the new path when route is a file name
i.e blank%20document.pdf
It does work when there is no .pdf on the end.

Related

Encountering error "Request has invalid Client token" but my credentials is correct

I'm having this error when I call the startDocumentTextDetection even I have the correct credentials because I was able to upload the my pdf in s3. I also allowed Textract to call other services on my behalf.
$client = new TextractClient([
'region' => env('AWS_DEFAULT_REGION'),
'version' => '2018-06-27',
'credentials' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY')
]
]);
$result = $client->startDocumentTextDetection([
'ClientRequestToken' => 'DocumentDetectionToken',
'DocumentLocation' => [ // REQUIRED
'S3Object' => [
'Bucket' => 'XXXXX',
'Name' => 'HNlLrVxE4cDqyJh0RHmSfTGtZVKzOWUG75ycHfyE.pdf',
],
],
'FeatureTypes' => ['FORMS','TABLES'],
'JobTag' => 'HNlLrVxE4cDqyJh0RHmSfTGtZVKzOWUG75ycHfyE.pdf',
'NotificationChannel' => [
'RoleArn' => 'XXXXX', // REQUIRED
'SNSTopicArn' => 'XXXXX', // REQUIRED
],
'OutputConfig' => [
'S3Bucket' => 'XXXXXX',
],
]);

Naming an AWS EC2 security group IP permissions rule

I am using the AWS PHP SDK version 3. I am able to create security groups using the API, as well as creating IP Permission rules. What I can't figure out is how give the IP Permissions rule a name.
Here's what I have:
$params =
[
'Description' => 'My Security Group',
'GroupName' => 'my_security_group',
'VpcId' => 'vpc-a9d2h3d7',
'TagSpecifications' => [
[
'ResourceType' => 'security-group',
'Tags' =>
[
['Key' => 'Name', 'Value' => 'My Security Group']
]
]
],
];
$Ec2Client->createSecurityGroup($params);
At this point the group is created
Then I create an IP Permissions rule:
$ip_permissions = [
'GroupName' => 'my_security_group',
'FromPort' => 0,
'ToPort' => 65535,
'IpProtocol' => 'tcp',
'IpRanges' => [['CidrIp' => 'xx.xxx.xx.xxxx/32', 'Description' => 'Main Office']],
];
$Ec2Client->authorizeSecurityGroupIngress($ip_permissions);
Through the AWS Console, I can see that the rule is created, but the Name column is empty. How do I create the Name through the API?
It would be same, by using TagSpecifications. But instead of security-group you need to have security-group-rule:
'TagSpecifications' => [
[
'ResourceType' => 'security-group-rule',
'Tags' =>
[
['Key' => 'Name', 'Value' => 'My Security Group Rule']
]
]
]
Full example in AWS CLI (don't have php):
aws ec2 authorize-security-group-ingress --group-id sg-00102bde0b55e29fe --ip-permissions FromPort=0,IpProtocol=tcp,IpRanges='[{CidrIp=10.10.10.10/32,Description="Main Office"}]',ToPort=65535 --tag-specifications ResourceType=security-group-rule,Tags='[{Key=Name,Value=MyName}]'

Ruby AWS SDK (v2/v3) Tag spot instances

According to this link it is possible to tag spot fleet instances. Tags are automatically propagated to the launched instances. Is it possible to do the same for normal spot instances? My approach so far
ec2 = Aws::EC2::Resource.new({region: region, credentials: creds})
launch_specification ={
:security_groups => ['ccc'],
:ebs_optimized => true,
:image_id => "image_id",
:instance_type => "type",
:key_name => "key",
:placement => {:group_name => "ggg"},
:user_data => ""
}
resp = ec2.client.request_spot_instances(:instance_count => count,
:launch_specification => launch_specification,
:spot_price => price.to_s,
:type => 'one-time',
:dry_run => false
)
resp.spot_instance_requests.each do |sir|
ec2.create_tags({
dry_run: false,
resources: [sir.spot_instance_request_id],
tags: [
{
key: "owner",
value: "ooo",
},
],
})
end
Tags are created for for the spot_instance_request, but are not propagated to the launched instances.

The request signature we calculated does not match the signature you provided

I am using SES for sending email here is my code can you anybody tell me what is the problem ?
Is there anyone facing the same problem??
I have also check my credentials they are also correct.
$client = SesClient::factory(array(
'version'=> 'latest',
'region' => REGION,
'credentials' => array(
'key' => "AKIA***********",
'secret' => "AoIM6Z/clu********************",
),
));
try {
$result = $client->sendEmail([
'Destination' => [
'ToAddresses' => [
RECIPIENT,
],
],
'Message' => [
'Body' => [
'Html' => [
'Charset' => CHARSET,
'Data' => HTMLBODY,
],
'Text' => [
'Charset' => CHARSET,
'Data' => TEXTBODY,
],
],
'Subject' => [
'Charset' => CHARSET,
'Data' => SUBJECT,
],
],
'Source' => SENDER,
// If you are not using a configuration set, comment or delete the
// following line
'ConfigurationSetName' => CONFIGSET,
]);
$messageId = $result->get('MessageId');
echo("Email sent! Message ID: $messageId"."\n");
} catch (SesException $error) {
echo("The email was not sent. Error message: ".$error-
>getAwsErrorMessage()."\n");
}
}
After so much googling I found out that my credentials are wrong. Just regenerate the credentials, try it again and it should work. Another thing is that the when key includes '/', it will not work, so if your key contains '/', regenerate it.

Doctrine PDOException No such file or directory

I am using ZF2 with DoctrineOrm and have recently installed a local environment using vagrant on my mac running OSX (Yasomite).
Everything works as expected except I get the following error when I attempt to use Doctrine vendor tools:
./vendor/bin/doctrine-module orm:schema-tool:create --dump-sql
The error reads:
Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002]
No such file or directory' in
example.com/trunk/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43
EDIT
Line 43 from the offending class: parent::__construct($dsn, $user, $password, $options);
class PDOConnection extends PDO implements Connection, ServerInfoAwareConnection
{
public function __construct($dsn, $user = null, $password = null, array $options = null)
{
try {
parent::__construct($dsn, $user, $password, $options);
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('Doctrine\DBAL\Driver\PDOStatement', array()));
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (\PDOException $exception) {
throw new PDOException($exception);
}
}
When I dump the variables from the catch statement, they are as expected.
I can access the mysql location via adminer: http://192.168..../adminer/
And the website loads albeit with errors as I am unable to create the DB.
I remember when I originally set up my local MAMP environment having a similar problem and had to add the following line to my pdo settings:
/Applications/MAMP/tmp/mysql/mysql.sock
'connection' => [
'orm_default' => [
'driverClass' =>'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => [
'host' => 'localhost',
'port' => '3306',
'user' => 'games_cloud',
'password' => 'games_cloud',
'dbname' => 'games_cloud',
'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock'
]
]
],
I can't help but think that I need to do the same thing, however I am not really sure how to.
EDIT:
SSHing into the Vbox I see the socket is located here: /var/lib/mysql/mysql.sock
What would the correct settings be to connect to this? The following does not work:
'connection' => [
'orm_default' => [
'driverClass' =>'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => [
'host' => '192.168.56.101/',
'port' => '3306',
'user' => 'games_cloud',
'password' => 'games_cloud',
'dbname' => 'games_cloud',
'unix_socket' => '/var/lib/mysql/mysql.sock' //To use Doctrine Entity Generator
]
]
],
Any help would be appreciated!
Managed to get this to work, it was a setting:
'connection' => [
'orm_default' => [
'driverClass' =>'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => [
'host' => 'localhost',
'port' => '3306',
'user' => 'games_cloud',
'password' => 'games_cloud',
'dbname' => 'games_cloud',
'unix_socket' => '/var/lib/mysql/mysql.sock'
]
]
],