aws delete reports group history - amazon-web-services

I'm attempting to use the AWS CLI to delete the history of a codebuild reports-group. (Context: It was muddied when we were initially setting up these reports.)
I notice that it's possible to just delete the entire reports-group, but I only want to clear the history. Is there an easy way to delete the history without destroying the entire reports-group?
The man page gives options for deleting an individual report, but there are possibly 500+, and I've no idea how nor the intent to run that command that many times.
My man page diving so far has landed me here:
aws codebuild delete-reports help
So far I have also found batch-delete-builds, but there's no batch-delete-reports that I can tell. Should I just delete the reports-group or is there a command that just isn't named as expected?

there is no such api, you can delete the report group. https://docs.aws.amazon.com/cli/latest/reference/codebuild/delete-report-group.html

Related

Errors during deployment to AWS using Terraform (cdktf)

I am trying to create or update Lambdas on AWS using the Terraform CDKTF. During deployment, I am getting the error of
"An event source mapping with SQS arn (\" arn:aws:sqs:eu-west-2:*******:*****-*****-******** \") and function (\" ******-******-****** \") already exists. Please update or delete the existing mapping with UUID *******-****-****-****-***********"
**** are sensitive info I have swapped out.
Some of our Lambdas are called via SQS, which is what this mapping is referring to. I assumed the first fix would be to remove the mappings that might already exist (on a previous deployment that might have partly gone through), but I am unsure where to find them, nor if they are even available to delete. I originally assumed by calling cdktf deploy it would update these mappings and not throw the err at all.
Does anyone have any advice?
Your diagnosis seems right, there might be some stray resources left behind due to an aborted / unfinished Terraform run. You should be able to clean up after these runs by running terraform destroy in the stack directory ./cdktf.out/stacks/..../. That should delete all previously existing resources created through this Terraform stack.

AWS: Is there a way to delete every artifact using string matching?

I need to remove a lot of created resources in AWS. Buckets, Lambdas, cloudformation, and more. I know everything I need to delete will start with "ABC". Is there a way to just delete everything from the AWS CLI that starts with "ABC"? or even delete resource types that start with the string?
Sadly there is not a single command for all of these. You would have to create a custom script or program, e.g. in python, to list all your resources in questions, filter them out by name, and delete what is needed.
While it won't handle everything (CloudFormation isn't on their list, unfortunately), cloud-nuke can delete artifacts based on regex strings (both inclusive and exclusive) so this might be a good tool for most cases.

Export/Outputs that don't exist preventing stack from updating/deleting

Using serverless to deploy to AWS.
I created a Cognito user pool via serverless then realised I wanted to change it's attributes.
I couldn't deploy because you can't update attributes on an existing user pool.
"No problem - I'll just delete it and make it again" I thought. So I did.
But I had created two Outputs that referencing Client ID and Pool ID so now I get this:
Export alpha-UserPoolId cannot be deleted as it is in use by alpha-Stack
I can't see any way to remove theese references manually via the AWS console.
Anyone know what I can do to remove these dead references?
There's no option to manually remove an Output and I tried editing the template but it didn't seem to actually do anything.
Thanks
[EDIT: Check comments for full details on solution]
You have to edit the importing stack to not rely on these values, afterwards you can remove them.
As long as there is an Fn::ImportValue somewhere, it won't let you delete the export.
From the docs:
The following restrictions apply to cross stack references
...
You can't delete a stack if another stack references one of its outputs.
You can't modify or remove an output value that is referenced by another stack.

Two different interfaces for AWS Tag Editor?

It seems that there are two different Web UI for AWS Tag Editor (you need an AWS account to try them):
https://resources.console.aws.amazon.com/r/tags
I got this link from AWS Doc
https://eu-west-1.console.aws.amazon.com/resource-groups/tag-editor/find-resources?region=eu-west-1
In Management Console, if you select Resource Group > Tag Editor on the top of the console page, it will take you to this page
The two WebUI behave differently:
The former is global but the latter is region-specific (it will put you into a region even if you don't put the region parameter in the URL)
The former allows you to search for Not tagged in the filter; but the latter does not
The UI are slightly different
Is one of UI a newer version?
Update (2019-05-14)
(Please also see an explanation about the two links being NEW and OLD UIs that AWS offered at a certain point in time) By now the first link is gone. If you visit it, you will get a 404 Not Found error from AWS.
I am part of the team building the new Tag Editor. Yes, you are correct: Classic Tag Editor is deprecated, and will be shut down soon entirely. We are working on full feature parity between the two Editors, so you will very soon find everything you can do in the old one as well in the new one.
To add some more context on your different items below:
1) Both old and new Tag Editor use the same underlying tagging infrastructure, so this should never happen. Maybe there is some browser issue involved here? Feel free to open a support issue so we can look deeper into it, if this continues the case.
2) Yes, the new one also includes Lambda, and will very soon add more resource types. The same by the way for regions: The old Tag Editor supports not all regions, for example eu-north-1 or eu-west-3.
3) No, Route53 Hosted Zones are supported in both Editors. Route53 resources only exists in the us-east-1 region, so maybe you used the Tag Editor in another region?
4) Both Editors show the same data. The old editor merged what you used as Name Tag and the ID in the same field - in the new one, you see only the ID in the column ID, and the Name Tag is displayed in the column Tag: Name.
Searching across regions is something the new Editor soon will support, too, and the same applies for the filter you mention. For showing resources without a specific tag, there is a workaround you already can do: Click on the settings icon in the top right of the table, and enable the tag you are interested in as a column. You then can sort this column so that all untagged ones show up on top.
If you have any other ideas or requests for the Tag Editor, please let us know. The fastest and most reliable way is to just use the 'Feedback' Button in the console in the bottom left.
Cheers,
Florian
Hi I am providing my own answer here (thanks my colleagues Kannan for the insight)
#1 above is what AWS called Class Tag Editor. If you click on the Question mark on the Web UI (upper right corner), you will be taken to a page that says:
This documentation is for classic Tag Editor, which has been
deprecated
So #2 is the version that AWS want us to use.
Below I will called #1 Old and #2 New
I compared the example outputs from our environment (about 50 resources). The two outputs differ in these respects:
New seems to retain past resources for a longer time. For example, if an EC2 instance has been terminated, it may take a
longer time to be removed from the listing of New
New seems to include resources for DynamoDB but Old does not
Old seems to include resources for Route 53 Hosted Zones but New does not.
Both New and Old show Security Groups, but the ID strings are rendered slightly differently.
New renders an ID as sg-xxxxxxxxxxxxxxxxxxxxxx
Old renders an ID as someName (sg-xxxxxxxxxxxxxxxxx)

AWS Lambda: unable to delete arn because it is a replicated function

I'm trying to delete an AWS Lambda function through the GUI, but am getting a response: There was an error deleting your function: Lambda was unable to delete arn:aws:lambda:us-east-1:624929674184:function:lambda-auth:1 because it is a replicated function.
How can one delete replicated Lambda functions?
I have figured out the solution to delete Lambda#edge replica.
Firstly, Login to CloudFront Console and go to your Distribution.
Under the Behaviors Tab - tick the listed Behavior and edit
Scroll down to Lambda Function Associations and remove any Association by clicking the X.
Press yes,edit to save the changes.
--- Now that you have removed the Associations it's time to delete the Lambda#edge replicas
Go to Lambda Console and open your lambda( you wish to delete).
On the top menus - Qualifiers -> Versions-> choose the listed drop-down version
It will open that #edgeLambda Version
On the top menus - Actions -> Delete version
This way , deleting all the versions - you are left with $LATEST
Deleting that also - you are finally able to delete the Lambda#edge Function
Note!> Please remember to delete any IAM Roles and Permissions associated with Lambda#edge Functions.
I hope this will work :)
Please refer the link Delete Lambda#Edge Functions and Replicas, you will find it much useful.
Replicated functions are something Lambda#Edge uses, so I assume that's the case here even though it's not stated. You should review this document on how to delete these. You can't manually delete them at this time:
You can delete a Lambda#Edge function only when the replicas of the
function have been deleted by CloudFront. Replicas of a Lambda
function are automatically deleted in the following situations:
After you have removed the last association for the function from all
of your CloudFront distributions. If more than one distribution uses a
function, the replicas are removed only after the function is
disassociated from the last one.
After you delete the last distribution that a function was associated
with.
Replicas are typically deleted within a few hours.
Note:
Replicas cannot be manually deleted at this time. This helps prevent a situation where a replica is removed that you're still using, which would result in an error.
BHEERAJ's answer is good, but in my exact case I waited like 6 hours and nothing changed and the error was still ocurring, but then I also removed related S3 buckets (and to remove the bucket, I had to remove items inside it first):
https://s3.console.aws.amazon.com/s3
Then in about half a hour I tried to remove those Lambda functions, and finally it actually deleted.