You can get the value of the minimum width
key using \pgfkeysvalueof{/pgf/minimum width}
etc. and use it with \resizebox
(graphicx
package, already loaded by tikz
} to resize the content to it. For the diamond
shape you might want to reduce the width a little more (e.g. to 90%; for tall texts even down to 50%), otherwise the text will touch the lines.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}[D/.style={shape=diamond, draw, line width=0.2pt, minimum width=0.8cm, minimum height=0.8cm,inner sep=0pt}]
\node [D] (m) {\setkeys{Gin}{keepaspectratio}\resizebox{\pgfkeysvalueof{/pgf/minimum width}}{\pgfkeysvalueof{/pgf/minimum width}}{AAAAAAAA}};
\node [D] (k) at (2,0) {\setkeys{Gin}{keepaspectratio}\resizebox{.9\dimexpr\pgfkeysvalueof{/pgf/minimum width}\relax}{.9\dimexpr\pgfkeysvalueof{/pgf/minimum height}\relax}{AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA}};
\end{tikzpicture}
\end{document}

You can also use adjustbox
for easy further adjustments, e.g. to allow line breaks. The similar TikZ options won't work as normal because \resizebox
is used.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usepackage{adjustbox}
\begin{document}
\begin{tikzpicture}[D/.style={shape=diamond, draw, line width=0.2pt, minimum width=0.8cm, minimum height=0.8cm,inner sep=0pt}]
\node [D] (m) {\setkeys{Gin}{keepaspectratio}\resizebox{\pgfkeysvalueof{/pgf/minimum width}}{\pgfkeysvalueof{/pgf/minimum width}}{AAAAAAAA}};
\node [D] (k) at (2,0) {\adjustbox{varwidth={5cm}\centering,keepaspectratio,width=.9\dimexpr\pgfkeysvalueof{/pgf/minimum width}\relax,height=.9\dimexpr\pgfkeysvalueof{/pgf/minimum height}\relax}{AAAAAAAAAAAAAA\\BBBBBBBBBBBB\\CCCCCCCCC}};
\end{tikzpicture}
\end{document}

Finally there is the min size
key of \adjustbox
which will scale the content down only if required (i.e. it is too large), but keep it the original size otherwise. You might want to define a shortcut macro if you need this more often.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usepackage{adjustbox}
\newcommand{\adjsizetonode}{%
\adjustbox{varwidth={5cm}\centering,keepaspectratio,max size={.9\dimexpr\pgfkeysvalueof{/pgf/minimum width}\relax}{.9\dimexpr\pgfkeysvalueof{/pgf/minimum height}\relax}}%
}
\begin{document}
\begin{tikzpicture}[D/.style={shape=diamond, draw, line width=0.2pt, minimum width=0.8cm, minimum height=0.8cm,inner sep=0pt}]
\node [D] (A) at (0,0) {a};
\node [D] (A2) at (1,0) {\adjsizetonode{a}};
\node [D] (B) at (2,0) {\adjsizetonode{BBBBBBBBBBBBBBBBBB}};
\node [D] (B) at (3,0) {\adjsizetonode{BBBBBBBBBBBBBBBBBB\\bbbbbbbbbbbbb bbbbbbbb bbbb bbbb\\Bb bbfd kslkgldf }};
\end{tikzpicture}
\end{document}
