cloudformation validation not working locally on windows - validation

I'm trying to validate the cloudformation template using AWS CLI on my windows machine locally.
The command is:
aws cloudformation validate-template --template-body file:///C:/AWS/template.json
But Im getting below error:
Error parsing parameter '--template-body': Unable to load param file file:///C:/AWS/template.json: [Errno 2] No such file or directory: 'file:///C:/AWS/template.json'

You can check permission of AWS directory and your template.json file as well.
Sometimes in Windows system directory files you have created in system drive (C://) are user permission restricted. So, It will not allow to access any created file easily.
2nd Way:
You can upload your template to any s3 bucket and then validate your file using s3 url.
For that, aws cli has valid permission for that operations.
Below is the command you can try with changing s3 URL by pointing it to your bucket and stored file:
aws cloudformation validate-template --template-url https://s3.amazonaws.com/cloudformation-templates-us-east-1/S3_Bucket.template

Related

Trying to copy executable jar file into AWS ec2 instance but getting permission denied error

I want to deploy a spring-boot executable jar file into Amazon EC2 instance. I successfully logged in into the instance using pem file but I am unable to copy my Jar from local system location into ec2. the command I am using is
scp -i /Users/sandeepamarnath/Desktop/AWS/recovery-key.pem /Users/sandeepamarnath/Desktop/AWS/foodapp-0.0.1-SNAPSHOT.jar ec2-user#ec2-15-222-1-81.ca-central-1.compute.amazonaws.com:~
I am getting an error of permission denied like below:
Warning: Identity file /Users/sandeepamarnath/Desktop/AWS/recovery-key.pem not accessible: No such file or directory.
Permission denied (publickey).
lost connection
Screenshot of error
It seems you are logged into the ec2 host and trying to reference a file which is present in your local.
Run below command to transfer the file from local to ec2 hosts.
scp -i /Users/sandeepamarnath/Desktop/AWS/recovery-key.pem /Users/sandeepamarnath/Desktop/AWS/foodapp-0.0.1-SNAPSHOT.jar ec2-user#ec2-15-222-1-81.ca-central-1.compute.amazonaws.com:~
Don't login into the EC2 host, just run the above command from your local.

AWS CodeBuild + AWS Lambda = Error: Could not find the required 'MyAssembly.deps.json'

I received following error in CloudWatch Logs after using AWS CodePipeline (AWS CodeBuild) to deploy my C# Lambda Function Code
Could not find the required 'MyAssembly.deps.json'.
This file should be present at the root of the deployment package.: LambdaException
The problem in my case was that the linux file permissions on files inside the Zip were set to 000; so when the zip was extracted by AWS Lambda; AWS Lambda did not have file permission to access the file MyAssembly.deps.json
I was using C# System.IO.Compression.ZipFile.CreateFromDirectory to author the zip file. I had to shell out to the native zip program to produce a zip file which worked.
Big thanks to https://forums.aws.amazon.com/message.jspa?messageID=856247
I know this is bit old question but writing answer for any user who are still facing the problem on windows system.
this is with dotnet core 3.1
The first command in package manager console to ensure the .deps.json included in publish files
dotnet publish /p:GenerateRuntimeConfigurationFiles=true
and than zip all files of publish folder in the same name of namespace folder. upload the zip file to AWS lambda using console.
worked.
If not than copy all project files ( not the published) in zip and upload to aws lambda.

How to write a binary file from AWS RDS Oracle database directory to local file system

How to write a binary file from AWS RDS Oracle database directory to local file system on EC2. I tried using Perl script with UTL_FILE, but it can't find read the file. Getting the permissions error.
In AWS RDS Oracle, you do not have access to the file system.
If you need access to the file system then you need to use instance EC2 and install the ORACLE RDBMS.
AWS has an option to integrate with S3: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/oracle-s3-integration.html
You could upload your files there and then download to your local machine. Here are steps to use it with Datapump: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Oracle.Procedural.Importing.html#Oracle.Procedural.Importing.DataPumpS3.Step1

Specify an AWS CLI profile in a script when two exist

I'm attempting to use a script which automatically creates snapshots of all EBS volumes on an AWS instance. This script is running on several other instances with no issue.
The current instance already has an AWS profile configured which is used for other purposes. My understanding is I should be able to specify the profile my script uses, but I can't get this to work.
I've added a new set of credentials to the /home/ubuntu/.aws file by adding the following under the default credentials which are already there:
[snapshot_creator]
aws_access_key_id=s;aldkas;dlkas;ldk
aws_secret_access_key=sdoij34895u98jret
In the script I have tried adding AWS_PROFILE=snapshot_creatorbut when I run it I get the error Unable to locate credentials. You can configure credentials by running "aws configure".
So, I delete my changes to /home/ubuntu/.aws and instead run aws configure --profile snapshot_creator. However after entering all information I get the error [Errno 17] File exists: '/home/ubuntu/.aws'.
So I add my changes to the .aws file again and this time in the script for every single command starting with aws ec2 I add the parameter --profile snapshot_creator, but this time when I run the script I get The config profile (snapshot_creator) could not be found.
How can I tell the script to use this profile? I don't want to change the environment variables for the instance because of the aforementioned other use of AWS CLI for other purposes.
Credentials should be stored in the file "/home/ubuntu/.aws/credentials"
I guess this error is because it couldn't create a directory. Can you delete the ".aws" file and re-run the configure command? It should create the credentials file under "/home/ubuntu/.aws/"
File exists: '/home/ubuntu/.aws'

Use current working directory as path with AWS Cli

I'm attempting to sync my bucket from my local directory using AWS Cli on Windows.
It works using the command
aws s3 sync C:\[long path name] s3://[bucket name]
I would prefer to replace the path name with something shorter or just associate it with the bucket. I've tried chdir and cd. Is there an easy way to do this?
If you wish to synchronize the current directory to an Amazon S3 bucket, use:
aws s3 sync . s3://[bucket name]
Or to sync to a directory within the S3 bucket:
aws s3 sync . s3://[bucket name]/[path]
The same syntax works on Windows and Linux.

Resources